Skip to content

Commit b047690

Browse files
committed
perf: avoid mutating internal state if setting state to current re: #11380
1 parent 865a8f2 commit b047690

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/statemachine.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ StateMachine.ctor = function() {
6565
*/
6666

6767
StateMachine.prototype._changeState = function _changeState(path, nextState) {
68-
const prevBucket = this.states[this.paths[path]];
68+
const prevState = this.paths[path];
69+
if (prevState === nextState) {
70+
return;
71+
}
72+
const prevBucket = this.states[prevState];
6973
if (prevBucket) delete prevBucket[path];
7074

7175
this.paths[path] = nextState;

lib/types/array/methods/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ const methods = {
375375
atomics.$push = val;
376376
} else {
377377
if (val.length === 1) {
378-
atomics.$push.$each.push(val);
378+
atomics.$push.$each.push(val[0]);
379379
} else if (val.length < 10000) {
380380
atomics.$push.$each.push(...val);
381381
} else {

0 commit comments

Comments
 (0)