-
Notifications
You must be signed in to change notification settings - Fork 187
chore: Matching on seq #2561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Matching on seq #2561
Conversation
| 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] |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
|
#2562 is merged |
|
@pjfanning Cool~ |
The pr against Scala is rejected, so I need to handle it here.