Skip to content

Commit 9274e14

Browse files
committed
timers: cleanup extraneous property on Immediates
This was originally changed in 6f75b66 but it appears unnecessary and benhcmark results show little difference without the extra property. Refs: nodejs#6436
1 parent d8c7534 commit 9274e14

File tree

4 files changed

+14
-18
lines changed

4 files changed

+14
-18
lines changed

lib/timers.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -586,8 +586,6 @@ function processImmediate() {
586586
if (domain)
587587
domain.enter();
588588

589-
immediate._callback = immediate._onImmediate;
590-
591589
// Save next in case `clearImmediate(immediate)` is called from callback
592590
var next = immediate._idleNext;
593591

@@ -646,16 +644,16 @@ function runCallback(timer) {
646644
switch (argc) {
647645
// fast-path callbacks with 0-3 arguments
648646
case 0:
649-
return timer._callback();
647+
return timer._onImmediate();
650648
case 1:
651-
return timer._callback(argv[0]);
649+
return timer._onImmediate(argv[0]);
652650
case 2:
653-
return timer._callback(argv[0], argv[1]);
651+
return timer._onImmediate(argv[0], argv[1]);
654652
case 3:
655-
return timer._callback(argv[0], argv[1], argv[2]);
653+
return timer._onImmediate(argv[0], argv[1], argv[2]);
656654
// more than 3 arguments run slower with .apply
657655
default:
658-
return timer._callback.apply(timer, argv);
656+
return timer._onImmediate.apply(timer, argv);
659657
}
660658
}
661659

@@ -665,7 +663,6 @@ function Immediate() {
665663
// so have caller annotate the object (node v6.0.0, v8 5.0.71.35)
666664
this._idleNext = null;
667665
this._idlePrev = null;
668-
this._callback = null;
669666
this._argv = null;
670667
this._onImmediate = null;
671668
this.domain = process.domain;
@@ -701,7 +698,6 @@ exports.setImmediate = function(callback, arg1, arg2, arg3) {
701698
function createImmediate(args, callback) {
702699
// declaring it `const immediate` causes v6.0.0 to deoptimize this function
703700
var immediate = new Immediate();
704-
immediate._callback = callback;
705701
immediate._argv = args;
706702
immediate._onImmediate = callback;
707703

test/message/eval_messages.out

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ SyntaxError: Strict mode code may not include a with statement
66
at Object.exports.runInThisContext (vm.js:*)
77
at Object.<anonymous> ([eval]-wrapper:*:*)
88
at Module._compile (module.js:*:*)
9-
at Immediate.<anonymous> (bootstrap_node.js:*:*)
9+
at Immediate._onImmediate (bootstrap_node.js:*:*)
1010
at runCallback (timers.js:*:*)
1111
at tryOnImmediate (timers.js:*:*)
1212
at processImmediate [as _immediateCallback] (timers.js:*:*)
@@ -21,7 +21,7 @@ Error: hello
2121
at Object.exports.runInThisContext (vm.js:*)
2222
at Object.<anonymous> ([eval]-wrapper:*:*)
2323
at Module._compile (module.js:*:*)
24-
at Immediate.<anonymous> (bootstrap_node.js:*:*)
24+
at Immediate._onImmediate (bootstrap_node.js:*:*)
2525
at runCallback (timers.js:*:*)
2626
at tryOnImmediate (timers.js:*:*)
2727
at processImmediate [as _immediateCallback] (timers.js:*:*)
@@ -34,7 +34,7 @@ Error: hello
3434
at Object.exports.runInThisContext (vm.js:*)
3535
at Object.<anonymous> ([eval]-wrapper:*:*)
3636
at Module._compile (module.js:*:*)
37-
at Immediate.<anonymous> (bootstrap_node.js:*:*)
37+
at Immediate._onImmediate (bootstrap_node.js:*:*)
3838
at runCallback (timers.js:*:*)
3939
at tryOnImmediate (timers.js:*:*)
4040
at processImmediate [as _immediateCallback] (timers.js:*:*)
@@ -48,7 +48,7 @@ ReferenceError: y is not defined
4848
at Object.exports.runInThisContext (vm.js:*)
4949
at Object.<anonymous> ([eval]-wrapper:*:*)
5050
at Module._compile (module.js:*:*)
51-
at Immediate.<anonymous> (bootstrap_node.js:*:*)
51+
at Immediate._onImmediate (bootstrap_node.js:*:*)
5252
at runCallback (timers.js:*:*)
5353
at tryOnImmediate (timers.js:*:*)
5454
at processImmediate [as _immediateCallback] (timers.js:*:*)

test/message/stdin_messages.out

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ SyntaxError: Strict mode code may not include a with statement
77
at Object.exports.runInThisContext (vm.js:*)
88
at Object.<anonymous> ([stdin]-wrapper:*:*)
99
at Module._compile (module.js:*:*)
10-
at Immediate.<anonymous> (bootstrap_node.js:*:*)
10+
at Immediate._onImmediate (bootstrap_node.js:*:*)
1111
at runCallback (timers.js:*:*)
1212
at tryOnImmediate (timers.js:*:*)
1313
at processImmediate [as _immediateCallback] (timers.js:*:*)
@@ -23,7 +23,7 @@ Error: hello
2323
at Object.exports.runInThisContext (vm.js:*)
2424
at Object.<anonymous> ([stdin]-wrapper:*:*)
2525
at Module._compile (module.js:*:*)
26-
at Immediate.<anonymous> (bootstrap_node.js:*:*)
26+
at Immediate._onImmediate (bootstrap_node.js:*:*)
2727
at runCallback (timers.js:*:*)
2828
at tryOnImmediate (timers.js:*:*)
2929
at processImmediate [as _immediateCallback] (timers.js:*:*)
@@ -37,7 +37,7 @@ Error: hello
3737
at Object.exports.runInThisContext (vm.js:*)
3838
at Object.<anonymous> ([stdin]-wrapper:*:*)
3939
at Module._compile (module.js:*:*)
40-
at Immediate.<anonymous> (bootstrap_node.js:*:*)
40+
at Immediate._onImmediate (bootstrap_node.js:*:*)
4141
at runCallback (timers.js:*:*)
4242
at tryOnImmediate (timers.js:*:*)
4343
at processImmediate [as _immediateCallback] (timers.js:*:*)
@@ -52,7 +52,7 @@ ReferenceError: y is not defined
5252
at Object.exports.runInThisContext (vm.js:*)
5353
at Object.<anonymous> ([stdin]-wrapper:*:*)
5454
at Module._compile (module.js:*:*)
55-
at Immediate.<anonymous> (bootstrap_node.js:*:*)
55+
at Immediate._onImmediate (bootstrap_node.js:*:*)
5656
at runCallback (timers.js:*:*)
5757
at tryOnImmediate (timers.js:*:*)
5858
at processImmediate [as _immediateCallback] (timers.js:*:*)

test/message/unhandled_promise_trace_warnings.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
at *
2626
at Promise.then (native)
2727
at Promise.catch (native)
28-
at Immediate.setImmediate (*test*message*unhandled_promise_trace_warnings.js:*)
28+
at Immediate.setImmediate [as _onImmediate] (*test*message*unhandled_promise_trace_warnings.js:*)
2929
at *
3030
at *
3131
at *

0 commit comments

Comments
 (0)