diff options
Diffstat (limited to 'lib/CallbackWrapper.jsm')
-rw-r--r-- | lib/CallbackWrapper.jsm | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/CallbackWrapper.jsm b/lib/CallbackWrapper.jsm index 1d3664e..55fdf11 100644 --- a/lib/CallbackWrapper.jsm +++ b/lib/CallbackWrapper.jsm @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see {http://www.gnu.org/licenses/}. - Home: https://gitlab.com/vannilla/ematrix + Home: https://libregit.org/heckyel/ematrix uMatrix Home: https://github.com/gorhill/uMatrix */ @@ -28,7 +28,7 @@ var EXPORTED_SYMBOLS = ['CallbackWrapper']; var junkyard = []; var CallbackWrapper = function (messageManager, channelName, - listenerId, requestId) { + listenerId, requestId) { // This allows to avoid creating a closure for every single // message which expects an answer. Having a closure created // each time a message is processed has been always bothering @@ -52,19 +52,19 @@ var CallbackWrapper = function (messageManager, channelName, }; CallbackWrapper.factory = function (messageManager, channelName, - listenerId, requestId) { + listenerId, requestId) { let wrapper = junkyard.pop(); if (wrapper) { wrapper.init(messageManager, channelName, listenerId, requestId); return wrapper; } - + return new CallbackWrapper(messageManager, channelName, - listenerId, requestId); + listenerId, requestId); }; CallbackWrapper.prototype.init = function (messageManager, channelName, - listenerId, requestId) { + listenerId, requestId) { this.messageManager = messageManager; this.channelName = channelName; this.listenerId = listenerId; @@ -86,7 +86,7 @@ CallbackWrapper.prototype.proxy = function (response) { // Mark for reuse this.messageManager = this.channelName = - this.requestId = this.listenerId = null; - + this.requestId = this.listenerId = null; + junkyard.push(this); }; |