-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
timers: simplify the compareTimersLists function #57110
timers: simplify the compareTimersLists function #57110
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #57110 +/- ##
==========================================
- Coverage 90.37% 90.34% -0.03%
==========================================
Files 629 629
Lines 184365 184362 -3
Branches 36016 36021 +5
==========================================
- Hits 166612 166570 -42
- Misses 10918 10922 +4
- Partials 6835 6870 +35
🚀 New features to boost your workflow:
|
671d927
to
9239cba
Compare
Can we get this merged? |
@atlowChemi can you take a look as well? |
Landed in 7c2709d |
This PR landed without benchmark-ci even though there was a needs-benchmark-ci label. cc @atlowChemi |
@anonrig I totally, missed that 😕 I ran now a benchmark CI, should we add a don't land until the benchmarks have run? https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1676/ |
|
Code is a lot simpler, and I'm fine with landing this but the performance claim seems to be invalid. |
Well, locally I saw a small improvement but in any case it was clear to me this wouldn't be a 200% improvement I just wanted to simplify the function by returning directly here, because the result will get compared with 0 anyway in the priority queue In terms of V8 and JS bytecode, this forces a Number result with a constant subtraction operation instead of doing 2 separate comparisons at worst case, I'd say it should perform just as well or slightly better in a certain scenario where the ids are the same |
PR-URL: #57110 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Jason Zhang <xzha4350@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
PR-URL: #57110 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Jason Zhang <xzha4350@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Simplifies the compare function by returning directly if
expiryDiff
is equal to 0We don't need to compare twice here, or return 1 or -1 -- if the ids are equal, which only happens if the same object is passed, we can just return the result of the difference as
expiryDiff
is 0 tooBefore:
After: