@colyseus/schema 2.0.11 → 2.0.13

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.
@@ -411,6 +411,10 @@ class ArraySchema {
411
411
  console.error("ArraySchema items cannot be null nor undefined; Use `deleteAt(index)` instead.");
412
412
  return;
413
413
  }
414
+ // skip if the value is the same as cached.
415
+ if (this.$items.get(index) === value) {
416
+ return;
417
+ }
414
418
  if (value['$changes'] !== undefined) {
415
419
  value['$changes'].setParent(this, this.$changes.root, index);
416
420
  }
@@ -889,6 +893,11 @@ class MapSchema {
889
893
  this.$changes.indexes[key] = index;
890
894
  this.$indexes.set(index, key);
891
895
  }
896
+ else if (!isRef &&
897
+ this.$items.get(key) === value) {
898
+ // if value is the same, avoid re-encoding it.
899
+ return;
900
+ }
892
901
  else if (isRef && // if is schema, force ADD operation if value differ from previous one.
893
902
  this.$items.get(key) !== value) {
894
903
  operation = OPERATION.ADD;