@jbrowse/mobx-state-tree 5.11.0 → 5.11.1

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.
@@ -5899,6 +5899,18 @@ function defaultSnapshotEquals(a, b) {
5899
5899
  a !== null &&
5900
5900
  typeof b === "object" &&
5901
5901
  b !== null) {
5902
+ // Cheap structural short-circuit before the full stringify compare: a
5903
+ // value of a different size can't equal the default, so the common strip
5904
+ // case (non-empty value vs an empty `[]`/`{}` default) avoids stringifying
5905
+ // a potentially large snapshot on every getSnapshot.
5906
+ if (Array.isArray(a) !== Array.isArray(b)) {
5907
+ return false;
5908
+ }
5909
+ const aSize = Array.isArray(a) ? a.length : Object.keys(a).length;
5910
+ const bSize = Array.isArray(b) ? b.length : Object.keys(b).length;
5911
+ if (aSize !== bSize) {
5912
+ return false;
5913
+ }
5902
5914
  return JSON.stringify(a) === JSON.stringify(b);
5903
5915
  }
5904
5916
  return false;