perf: Use for loops while cloning classes

This commit is contained in:
Daniel Tschinder
2019-01-16 19:35:07 -08:00
parent f216975378
commit f12905b531
2 changed files with 12 additions and 7 deletions

View File

@@ -178,7 +178,9 @@ export default class State {
clone(skipArrays?: boolean): State {
const state = new State();
Object.keys(this).forEach(key => {
const keys = Object.keys(this);
for (let i = 0, length = keys.length; i < length; i++) {
const key = keys[i];
// $FlowIgnore
let val = this[key];
@@ -188,7 +190,8 @@ export default class State {
// $FlowIgnore
state[key] = val;
});
}
return state;
}
}