Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Cache the result of Date.now() in a variable

  • Loading branch information...
commit 4afb40fe6adb57b4f8b9c2d995fa9378a0f1b613 1 parent 4ade1b8
@bnoordhuis bnoordhuis authored committed
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/timers.js
View
5 lib/timers.js
@@ -264,8 +264,9 @@ var Timeout = function(after) {
Timeout.prototype.unref = function() {
if (!this._handle) {
- if (!this._idleStart) this._idleStart = Date.now();
- var delay = this._idleStart + this._idleTimeout - Date.now();
+ var now = Date.now();
+ if (!this._idleStart) this._idleStart = now;
+ var delay = this._idleStart + this._idleTimeout - now;
if (delay < 0) delay = 0;
exports.unenroll(this);
this._handle = new Timer();
Please sign in to comment.
Something went wrong with that request. Please try again.