Skip to content

Commit

Permalink
feat: optimize performance (#18)
Browse files Browse the repository at this point in the history
Change `Infinity` to `this._readyCallbacks.length`.
I have tested in little number:

<img
src="https://raw.githubusercontent.com/brizer/graph-bed/master/img/20190927095144.png"/>

and large number:

<img
src="https://raw.githubusercontent.com/brizer/graph-bed/master/img/20190927100947.png"/>

The hack of Infinity is unnecessary. If there is anything I didn't think
about, please correct me.
  • Loading branch information
brizer authored Dec 3, 2022
1 parent bbea174 commit 07d55e8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class Base extends EventEmitter {
}

if (this._ready || this._readyError) {
this._readyCallbacks.splice(0, Infinity).forEach(callback => {
this._readyCallbacks.splice(0, this._readyCallbacks.length).forEach(callback => {
process.nextTick(() => {
callback(this._readyError);
});
Expand Down

0 comments on commit 07d55e8

Please sign in to comment.