You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pekko.apache.org by he...@apache.org on 2025/12/08 03:28:16 UTC

(pekko) branch singleSeq created (now 80fca02ac6)

This is an automated email from the ASF dual-hosted git repository.

hepin pushed a change to branch singleSeq
in repository https://gitbox.apache.org/repos/asf/pekko.git


      at 80fca02ac6 chore: Matching on seq

This branch includes the following new commits:

     new 80fca02ac6 chore: Matching on seq

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pekko.apache.org
For additional commands, e-mail: commits-help@pekko.apache.org


(pekko) 01/01: chore: Matching on seq

Posted by he...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hepin pushed a commit to branch singleSeq
in repository https://gitbox.apache.org/repos/asf/pekko.git

commit 80fca02ac61857b659b3d0c79b8d2835544f4d85
Author: He-Pin <he...@gmail.com>
AuthorDate: Mon Dec 8 11:28:03 2025 +0800

    chore: Matching on seq
---
 .../scala/org/apache/pekko/stream/scaladsl/Source.scala  | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/stream/src/main/scala/org/apache/pekko/stream/scaladsl/Source.scala b/stream/src/main/scala/org/apache/pekko/stream/scaladsl/Source.scala
index c08b7de18a..5140b02887 100644
--- a/stream/src/main/scala/org/apache/pekko/stream/scaladsl/Source.scala
+++ b/stream/src/main/scala/org/apache/pekko/stream/scaladsl/Source.scala
@@ -402,13 +402,15 @@ object Source {
    * stream will see an individual flow of elements (always starting from the
    * beginning) regardless of when they subscribed.
    */
-  def apply[T](iterable: immutable.Iterable[T]): Source[T, NotUsed] = {
-    (iterable.knownSize: @switch) match {
-      case 0 => empty
-      case 1 => single(iterable.head)
-      case _ =>
-        fromGraph(new IterableSource[T](iterable)).withAttributes(DefaultAttributes.iterableSource)
-    }
+  def apply[T](iterable: immutable.Iterable[T]): Source[T, NotUsed] = iterable match {
+    case immutable.Seq()     => empty[T]
+    case immutable.Seq(elem) => single(elem)
+    case other               => (other.knownSize: @switch) match {
+        case 0 => empty
+        case 1 => single(iterable.head)
+        case _ =>
+          fromGraph(new IterableSource[T](iterable)).withAttributes(DefaultAttributes.iterableSource)
+      }
   }
 
   /**


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pekko.apache.org
For additional commands, e-mail: commits-help@pekko.apache.org