Skip to content

Conversation

@He-Pin
Copy link
Member

@He-Pin He-Pin commented Dec 8, 2025

The pr against Scala is rejected, so I need to handle it here.

@He-Pin He-Pin requested a review from mdedetrich December 8, 2025 03:32
@He-Pin He-Pin added the t:stream Pekko Streams label Dec 8, 2025
@He-Pin He-Pin added this to the 2.0.0-M2 milestone Dec 8, 2025
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]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Member Author

@He-Pin He-Pin Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's vs the materialization

def apply[T](iterable: immutable.Iterable[T]): Source[T, NotUsed] = iterable match {
case immutable.Seq() => empty[T]
case immutable.Seq(elem: T @unchecked) => single(elem)
case other => (other.knownSize: @switch) match {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment saying that if the Iterable has unknown size, that knownSize returns -1?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not unknown size,just the size can or not been cheaply cimputed

@pjfanning
Copy link
Member

#2562 is merged

@He-Pin He-Pin closed this Dec 10, 2025
@He-Pin He-Pin deleted the singleSeq branch December 10, 2025 10:48
@He-Pin
Copy link
Member Author

He-Pin commented Dec 10, 2025

@pjfanning Cool~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t:stream Pekko Streams

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants