-
Notifications
You must be signed in to change notification settings - Fork 500
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: optimize HeadersList.clear #2457
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.
I'm all for optimizing, but when would someone ever clear an empty Headers? It seems like a case that would never happen.
The headersList is empty unless the first argument of the Request constructor is Request |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #2457 +/- ##
==========================================
+ Coverage 85.54% 85.62% +0.07%
==========================================
Files 76 77 +1
Lines 6858 7055 +197
==========================================
+ Hits 5867 6041 +174
- Misses 991 1014 +23 ☔ View full report in Codecov by Sentry. |
@KhafraDev The same logic is used here. Lines 227 to 237 in 0437f69
|
That's not quite the same. It avoids creating an unnecessary iterator. But yea, I would argue it's unnecessary there as well. |
On second thought, this does not seem necessary. |
That optimization makes much more sense because headers received from the server are immutable |
Rationale
Checking the Map size and not clearing is thirty times faster if the map is empty.
Status