pjfanning commented on code in PR #2561:
URL: https://github.com/apache/pekko/pull/2561#discussion_r2599091229
##########
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]
Review Comment:
I don't see how adding extra checks, including instanceof checks, improves
performance. Is there any way that we could keep a variant of the old code from
the recent other PR that introduced changes?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]