db/SessionStore.js: call nextTick() only if there is something to do

Changed two occurrences of:

  process.nextTick(function() {
     if (fn) fn();
  });

with

  if (fn) {
    process.nextTick(fn);
  }

i.e. such that no function even gets added to the `nextTick` queue unless
there's actually a function to be called.

Extracted from Ray's work.
pull/3559/head
muxator 2019-02-09 00:14:53 +01:00
parent 96d875b4d1
commit 630af9af7d
1 changed files with 6 additions and 6 deletions

View File

@ -36,18 +36,18 @@ SessionStore.prototype.set = function(sid, sess, fn) {
messageLogger.debug('SET ' + sid);
db.set("sessionstorage:" + sid, sess);
process.nextTick(function() {
if (fn) fn();
});
if (fn) {
process.nextTick(fn);
}
};
SessionStore.prototype.destroy = function(sid, fn) {
messageLogger.debug('DESTROY ' + sid);
db.remove("sessionstorage:" + sid);
process.nextTick(function() {
if (fn) fn();
});
if (fn) {
process.nextTick(fn);
}
};
SessionStore.prototype.all = function(fn) {