Skip to content

Commit aedb72e

Browse files
evanlucasjasnell
authored andcommitted
process: improve performance of nextTick
This replaces TickObject with an object literal. This offers performance improvements of up to ~20%. PR-URL: #8932 Reviewed-By: Claudio Rodriguez <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Ilkka Myller <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Johan Bergström <[email protected]> Reviewed-By: Trevor Norris <[email protected]>
1 parent cde2ca9 commit aedb72e

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

lib/internal/process/next_tick.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,6 @@ function setupNextTick() {
131131
} while (tickInfo[kLength] !== 0);
132132
}
133133

134-
function TickObject(c, args) {
135-
this.callback = c;
136-
this.domain = process.domain || null;
137-
this.args = args;
138-
}
139-
140134
function nextTick(callback) {
141135
if (typeof callback !== 'function')
142136
throw new TypeError('callback is not a function');
@@ -151,7 +145,11 @@ function setupNextTick() {
151145
args[i - 1] = arguments[i];
152146
}
153147

154-
nextTickQueue.push(new TickObject(callback, args));
148+
nextTickQueue.push({
149+
callback,
150+
domain: process.domain || null,
151+
args
152+
});
155153
tickInfo[kLength]++;
156154
}
157155
}

0 commit comments

Comments
 (0)