-
Notifications
You must be signed in to change notification settings - Fork 412
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
Optimise HttpContentCodec#lookup
#3024
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.
Damn you're getting good. 😆
bdc19e3
to
1bfb93e
Compare
@jdegoes Thanks! I'm copying from some of the optimisations I see made by Kyri in ZIO! 🙂 We have a discussion with @987Nabil in Discord tho. What's your opinion about that? |
@jdegoes I was also wondering, if small HashMaps (4 or 5 elements max) are slower then the default map. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #3024 +/- ##
==========================================
+ Coverage 64.78% 65.27% +0.48%
==========================================
Files 157 155 -2
Lines 9395 10127 +732
Branches 1743 1886 +143
==========================================
+ Hits 6087 6610 +523
- Misses 3308 3517 +209 ☔ View full report in Codecov by Sentry. |
I might be missing something, but this looks like an ideal situation to use a mutable map instead of an immutable one with a |
@kyri-petrou I don't think in this case it makes any significant difference between var or mutable. Because the writes are probably just a very few. This is read heavy |
@987Nabil In that case I'd leave the implementation as is then (using |
@guizmaii by the way I recently came across a small trick that might be good to apply here. To avoid the Function0 allocation in val map: Map[String, String] = ???
private val orElseNull: () => String = () => null
map.getOrElse("foo", orElseNull()) This avoids the allocation because Scala 3 only: |
@guizmaii I just found out something interesting (or maybe a bug in dotty?). In Scala 2 this optimization works out of the box, but in Scala 3 it only works if you use the |
5881cd9
to
6f36929
Compare
} | ||
|
||
// Required for @static fields | ||
private final class syntax private |
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.
@kyri-petrou What is this for? Do I need it? 🤔
@987Nabil @kyri-petrou I made the changes you asked for :) |
6f36929
to
8546913
Compare
@guizmaii I think something of the optimizing is not working with scala js |
@guizmaii I close PRs to have a better overview what is needed for 3.0 |
See also ghostdogpr/caliban#2366