From 630af9af7d673b8547e72bc8e3296dc7207b6c28 Mon Sep 17 00:00:00 2001 From: muxator Date: Sat, 9 Feb 2019 00:14:53 +0100 Subject: [PATCH] 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. --- src/node/db/SessionStore.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/node/db/SessionStore.js b/src/node/db/SessionStore.js index 80d35f290..b9686b19b 100644 --- a/src/node/db/SessionStore.js +++ b/src/node/db/SessionStore.js @@ -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) {