refactor(ivy): move all of the instruction state into a singe object (#33093)

Turns out that writing to global state is more expensive than writing to
a property on an object.

Slower:
````
let count = 0;

function increment() {
  count++;
}
```

Faster:
````
const state = {
  count: 0
};

function increment() {
  state.count++;
}
```

This change moves all of the instruction state into a single state object.

`noop_change_detection` benchmark
Pre refactoring: 16.7 us
Post refactoring: 14.523 us (-13.3%)

PR Close #33093
This commit is contained in:
Miško Hevery
2019-10-11 12:43:32 -07:00
committed by Matias Niemelä
parent 43487f6761
commit bb53b6549c
6 changed files with 214 additions and 184 deletions

View File

@ -184,7 +184,7 @@ function stylingProp(
// it's important we remove the current style sanitizer once the
// element exits, otherwise it will be used by the next styling
// instructions for the next element.
setElementExitFn(resetCurrentStyleSanitizer);
setElementExitFn(stylingApply);
}
} else {
// Context Resolution (or first update) Case: save the value
@ -354,7 +354,7 @@ function _stylingMap(
// it's important we remove the current style sanitizer once the
// element exits, otherwise it will be used by the next styling
// instructions for the next element.
setElementExitFn(resetCurrentStyleSanitizer);
setElementExitFn(stylingApply);
}
} else {
updated = valueHasChanged;