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

@ -140,21 +140,12 @@
{
"name": "__window"
},
{
"name": "_currentNamespace"
},
{
"name": "_elementExitFn"
},
{
"name": "_global"
},
{
"name": "_renderCompCount"
},
{
"name": "_selectedIndex"
},
{
"name": "addComponentLogic"
},
@ -188,9 +179,6 @@
{
"name": "callHooks"
},
{
"name": "checkNoChangesMode"
},
{
"name": "concatString"
},
@ -431,6 +419,9 @@
{
"name": "instantiateRootComponent"
},
{
"name": "instructionState"
},
{
"name": "invertObject"
},

View File

@ -125,18 +125,12 @@
{
"name": "__window"
},
{
"name": "_elementExitFn"
},
{
"name": "_global"
},
{
"name": "_renderCompCount"
},
{
"name": "_selectedIndex"
},
{
"name": "addToViewTree"
},
@ -158,9 +152,6 @@
{
"name": "callHooks"
},
{
"name": "checkNoChangesMode"
},
{
"name": "createLView"
},
@ -332,6 +323,9 @@
{
"name": "instantiateRootComponent"
},
{
"name": "instructionState"
},
{
"name": "invertObject"
},

View File

@ -326,33 +326,21 @@
{
"name": "_currentInjector"
},
{
"name": "_currentNamespace"
},
{
"name": "_devMode"
},
{
"name": "_elementExitFn"
},
{
"name": "_global"
},
{
"name": "_renderCompCount"
},
{
"name": "_selectedIndex"
},
{
"name": "_state"
},
{
"name": "_symbolIterator"
},
{
"name": "activeDirectiveId"
},
{
"name": "addBindingIntoContext"
},
@ -446,9 +434,6 @@
{
"name": "checkNoChangesInternal"
},
{
"name": "checkNoChangesMode"
},
{
"name": "cleanUpView"
},
@ -461,9 +446,6 @@
{
"name": "containerInternal"
},
{
"name": "contextLView"
},
{
"name": "createContainerRef"
},
@ -899,6 +881,9 @@
{
"name": "instantiateRootComponent"
},
{
"name": "instructionState"
},
{
"name": "interpolation1"
},