| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
As this module already uses const, maybe we can use const here too?
Sorry, something went wrong.
There was a problem hiding this comment.
fixed
Sorry, something went wrong.
|
Multiple early fails in the CI. Something is temporarily wrong? |
Sorry, something went wrong.
|
@bmeurer are there plans to optimize splice sometime "soon"? |
Sorry, something went wrong.
And Array.join: https://github.com/nodejs/node/blob/master/lib/internal/util.js#L261 |
Sorry, something went wrong.
|
We're working on Array#slice, but mostly on the clone case, which should also be usable for Array#splice. Which case is most interesting for Array#splice? As for Array#join (and Array#toString): One day... hopefully not too far away... |
Sorry, something went wrong.
There was a problem hiding this comment.
It must have a lazy load here because (#15623):
It is because events.js is loaded before all the other modules in the dependency tree (because of bootstrapping process. Lazy loading errors prevents errors from being loaded before events is loaded.
Sorry, something went wrong.
|
@vsemozhetbyt Could you please restart a new CI? |
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
Why not just use list.splice(position, 1) here?
This was introduced 3 years ago in d3f8db1
Sorry, something went wrong.
There was a problem hiding this comment.
According to #14082, it seems like Array#splice is still much slower than spliceOne.
Sorry, something went wrong.
There was a problem hiding this comment.
Than I'd rather have the simpler lazy loader, like #14167
var spliceOne;
...
if (!spliceOne) spliceOne = require('internal/util').spliceOne;
Sorry, something went wrong.
|
Run a microbenchmark: > console.time('native'); for (let i = 0; i < 1e8; ++i) { global.x = [1,2,3,4]; global.x.splice(2,1); };console.timeEnd('native')
native: 31554.122ms
> console.time('spliceOne'); for (let i = 0; i < 1e8; ++i) { global.x = [1,2,3,4]; spliceOne(global.x, 2); };console.timeEnd('spliceOne')
spliceOne: 3718.840msThat shows at ~10x better performance For url I get it, but IMHO removeListener is not a hot path and is not worth the lazy load mechanics. |
Sorry, something went wrong.
There was a problem hiding this comment.
It would be better to write
if (spliceOne === undefined) spliceOne = require('internal/util').spliceOne;Otherwise there is a type conversion while evalutating if spliceOne is truthy.
Sorry, something went wrong.
There was a problem hiding this comment.
Same code in https://github.com/nodejs/node/blob/master/lib/events.js#L74
Should I rewrite them all?
Sorry, something went wrong.
There was a problem hiding this comment.
I would keep it as is to reduce the churn.
Sorry, something went wrong.
There was a problem hiding this comment.
Existing code is tricky but when adding new code and we're certain that something is either defined or undefined then a strict comparison is always better.
(Also, for example, domain can be null or undefined and maybe even other falsey values that we don't test for.)
Sorry, something went wrong.
|
@refack EventEmitter#removeListener() is used extensively in _http_server.js so I'd say it's equally important. |
Sorry, something went wrong.
lib/url.js and lib/events.js are using the same spliceOne function. This change is to move it into the internal/util for avoiding duplicate code.
|
Pushed commit to address comment |
Sorry, something went wrong.
Sorry, something went wrong.
lib/url.js and lib/events.js are using the same spliceOne function. This change is to move it into the internal/util for avoiding duplicate code. PR-URL: #16221 Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
|
P.S. we should write a benchmark that compares the two so we know when V8 catches up. |
Sorry, something went wrong.
|
This does not land cleanly on the 8.x Would someone be willing to manually backport? |
Sorry, something went wrong.
lib/url.js and lib/events.js are using the same spliceOne function. This change is to move it into the internal/util for avoiding duplicate code. PR-URL: nodejs#16221 Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
lib/url.js and lib/events.js are using the same spliceOne function. This change is to move it into the internal/util for avoiding duplicate code. PR-URL: nodejs#16221 Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
lib/url.js and lib/events.js are using the same spliceOne function. This change is to move it into the internal/util for avoiding duplicate code. PR-URL: nodejs/node#16221 Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
lib/url.js and lib/events.js are using the same spliceOne function. This change is to move it into the internal/util for avoiding duplicate code. PR-URL: #16221 Backport-PR-URL: #16433 Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
lib/url.js and lib/events.js are using the same spliceOne function. This change is to move it into the internal/util for avoiding duplicate code. PR-URL: #16221 Backport-PR-URL: #16433 Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
|
Should this be backported to v6.x-staging? If yes please follow the guide and raise a backport PR, if not let me know or add the dont-land-on label. |
Sorry, something went wrong.
lib/url.js and lib/events.js are using the same spliceOne function. This change is to move it into the internal/util for avoiding duplicate code. PR-URL: nodejs/node#16221 Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
| Back | FazBrowse Home | New Git URL |
lib/url.js and lib/events.js are using the same spliceOne function.This change is to move it into the internal/util for avoiding duplicate code.
Checklist
Affected core subsystem(s)
url, events, util