From 768d82eb6c488b8d76ab0ec689ebee6518e8da8a Mon Sep 17 00:00:00 2001 From: Ilari Patrikka Date: Wed, 13 Jul 2016 01:37:48 +0300 Subject: [PATCH] Set stopped computation to null instead of delete (#7326) (#7328) * Set stopped computation to null instead of delete (#7326) Delete can be very slow. Setting the stopped computation property to null instead brings a speed gain of 3-10x. http://bertanguven.com/preventing-memory-leaks-in-javascript-null-vs-delete * add generated npm-shrinkwrap.json * Remove computation tracking from Tracker. --- packages/tracker/tracker.js | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/packages/tracker/tracker.js b/packages/tracker/tracker.js index 6926c2f03f..9f1ada8f9b 100644 --- a/packages/tracker/tracker.js +++ b/packages/tracker/tracker.js @@ -26,13 +26,6 @@ Tracker.active = false; */ Tracker.currentComputation = null; -// References to all computations created within the Tracker by id. -// Keeping these references on an underscore property gives more control to -// tooling and packages extending Tracker without increasing the API surface. -// These can used to monkey-patch computations, their functions, use -// computation ids for tracking, etc. -Tracker._computations = {}; - var setCurrentComputation = function (c) { Tracker.currentComputation = c; Tracker.active = !! c; @@ -203,9 +196,6 @@ Tracker.Computation = function (f, parent, onError) { self._onError = onError; self._recomputing = false; - // Register the computation within the global Tracker. - Tracker._computations[self._id] = self; - var errored = true; try { self._compute(); @@ -300,8 +290,6 @@ Tracker.Computation.prototype.stop = function () { if (! self.stopped) { self.stopped = true; self.invalidate(); - // Unregister from global Tracker. - delete Tracker._computations[self._id]; for(var i = 0, f; f = self._onStopCallbacks[i]; i++) { Tracker.nonreactive(function () { withNoYieldsAllowed(f)(self);