-
Notifications
You must be signed in to change notification settings - Fork 156
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
perf: Add dedicated collectFirst implementation. #1041
Conversation
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.
This new class looks a lot like existing Akka based code. Is it truly new? Otherwise, use the Lightbend and Apache header from the original file.
Yes it's totally new, I implemented with not looking at any code of the origin Collect and this mechanism is generic and not diverged from lightbend's code, otherwise, every class that extends the And you will see this kind of code in typelevel/fs2#3379 too and I chated at https://contributors.scala-lang.org/t/can-scala-compiler-do-the-micro-optimization-for-simple-pattern-matching/6493 |
bc24f2b
to
bcb7039
Compare
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.
lgtm
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.
lgtm
@pjfanning I can also confirm that if you wanted to write this from scratch it would also look like this. While it may look similar to existing akka code, there isn't much you can do about that because generally all of this code has the same style so if you want to write new functionality and keep the existing style it has a very high chance of looking this way.
Yes, we can ask anyone to write this code, and anyone's code will result in this style. |
Motivation:
Use dedicated collectFirst implementation
Result:
Better performance.