@lwc/engine-core 3.0.0 → 3.0.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.
package/dist/index.cjs.js CHANGED
@@ -255,10 +255,18 @@ class ReactiveObserver {
255
255
  const { listeners } = this;
256
256
  const len = listeners.length;
257
257
  if (len > 0) {
258
- for (let i = 0; i < len; i += 1) {
258
+ for (let i = 0; i < len; i++) {
259
259
  const set = listeners[i];
260
- const pos = shared.ArrayIndexOf.call(listeners[i], this);
261
- shared.ArraySplice.call(set, pos, 1);
260
+ if (set.length === 1) {
261
+ // Perf optimization for the common case - the length is usually 1, so avoid the indexOf+splice.
262
+ // If the length is 1, we can also be sure that `this` is the first item in the array.
263
+ set.length = 0;
264
+ }
265
+ else {
266
+ // Slow case
267
+ const pos = shared.ArrayIndexOf.call(set, this);
268
+ shared.ArraySplice.call(set, pos, 1);
269
+ }
262
270
  }
263
271
  listeners.length = 0;
264
272
  }
@@ -6937,5 +6945,5 @@ exports.swapTemplate = swapTemplate;
6937
6945
  exports.track = track;
6938
6946
  exports.unwrap = unwrap;
6939
6947
  exports.wire = wire;
6940
- /** version: 3.0.0 */
6948
+ /** version: 3.0.1 */
6941
6949
  //# sourceMappingURL=index.cjs.js.map