mobx 6.12.0 → 6.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1822,10 +1822,12 @@
1822
1822
  */
1823
1823
  function trackDerivedFunction(derivation, f, context) {
1824
1824
  var prevAllowStateReads = allowStateReadsStart(true);
1825
- // pre allocate array allocation + room for variation in deps
1826
- // array will be trimmed by bindDependencies
1827
1825
  changeDependenciesStateTo0(derivation);
1828
- derivation.newObserving_ = new Array(derivation.observing_.length + 100);
1826
+ // Preallocate array; will be trimmed by bindDependencies.
1827
+ derivation.newObserving_ = new Array(
1828
+ // Reserve constant space for initial dependencies, dynamic space otherwise.
1829
+ // See https://github.com/mobxjs/mobx/pull/3833
1830
+ derivation.runId_ === 0 ? 100 : derivation.observing_.length);
1829
1831
  derivation.unboundDepsCount_ = 0;
1830
1832
  derivation.runId_ = ++globalState.runId;
1831
1833
  var prevTracking = globalState.trackingDerivation;
@@ -2666,7 +2668,6 @@
2666
2668
  var firstTime = true;
2667
2669
  var isScheduled = false;
2668
2670
  var value;
2669
- var oldValue;
2670
2671
  var equals = opts.compareStructural ? comparer.structural : opts.equals || comparer["default"];
2671
2672
  var r = new Reaction(name, function () {
2672
2673
  if (firstTime || runSync) {
@@ -2682,12 +2683,12 @@
2682
2683
  return;
2683
2684
  }
2684
2685
  var changed = false;
2686
+ var oldValue = value;
2685
2687
  r.track(function () {
2686
2688
  var nextValue = allowStateChanges(false, function () {
2687
2689
  return expression(r);
2688
2690
  });
2689
2691
  changed = firstTime || !equals(value, nextValue);
2690
- oldValue = value;
2691
2692
  value = nextValue;
2692
2693
  });
2693
2694
  if (firstTime && opts.fireImmediately) {
@@ -3994,7 +3995,7 @@
3994
3995
  return dehancedValues[funcName].apply(dehancedValues, arguments);
3995
3996
  };
3996
3997
  }
3997
- // Make sure callbacks recieve correct array arg #2326
3998
+ // Make sure callbacks receive correct array arg #2326
3998
3999
  function mapLikeFunc(funcName) {
3999
4000
  return function (callback, thisArg) {
4000
4001
  var _this2 = this;
@@ -4006,7 +4007,7 @@
4006
4007
  });
4007
4008
  };
4008
4009
  }
4009
- // Make sure callbacks recieve correct array arg #2326
4010
+ // Make sure callbacks receive correct array arg #2326
4010
4011
  function reduceLikeFunc(funcName) {
4011
4012
  return function () {
4012
4013
  var _this3 = this;
@@ -5339,7 +5340,7 @@
5339
5340
  _this.spliceWithArray(0, 0, initialValues);
5340
5341
  }
5341
5342
  if (safariPrototypeSetterInheritanceBug) {
5342
- // Seems that Safari won't use numeric prototype setter untill any * numeric property is
5343
+ // Seems that Safari won't use numeric prototype setter until any * numeric property is
5343
5344
  // defined on the instance. After that it works fine, even if this property is deleted.
5344
5345
  Object.defineProperty(_assertThisInitialized(_this), "0", ENTRY_0);
5345
5346
  }