refactor(ivy): moved wrapped reference to 0 position in array (#28947)

`LView`, `LContainer`, `StylingContext` are all arrays which wrap either
an `HTMLElement`, `LView`, `LContainer`, `StylingContext`. It is often
necessary to retrieve the correct type of element from the location
which means that we often have to wrap the arrays. Logically it makes
more sense if the thing  which we are wrapping is at `0` location. Also
it may be more performant since data is more local which may result in
more L2 cache hits in CPU.
PR Close #28947
This commit is contained in:
Misko Hevery
2019-02-23 09:45:55 -08:00
committed by Miško Hevery
parent 1930e8a072
commit bd65f58784
6 changed files with 61 additions and 61 deletions

View File

@ -260,6 +260,11 @@ import {PlayerContext} from './player';
*/
export interface StylingContext extends
Array<{[key: string]: any}|number|string|boolean|RElement|StyleSanitizeFn|PlayerContext|null> {
/**
* Location of element that is used as a target for this context.
*/
[StylingIndex.ElementPosition]: RElement|null;
/**
* A numeric value representing the configuration status (whether the context is dirty or not)
* mixed together (using bit shifting) with a index value which tells the starting index value
@ -289,11 +294,6 @@ export interface StylingContext extends
*/
[StylingIndex.SinglePropOffsetPositions]: SinglePropOffsetValues;
/**
* Location of element that is used as a target for this context.
*/
[StylingIndex.ElementPosition]: RElement|null;
/**
* The last class value that was interpreted by elementStylingMap. This is cached
* So that the algorithm can exit early incase the value has not changed.
@ -614,18 +614,18 @@ export const enum StylingFlags {
/** Used as numeric pointer values to determine what cells to update in the `StylingContext` */
export const enum StylingIndex {
// Index of location where the start of single properties are stored. (`updateStyleProp`)
MasterFlagPosition = 0,
// Position of where the registered directives exist for this styling context
DirectiveRegistryPosition = 1,
// Position of where the initial styles are stored in the styling context
InitialStyleValuesPosition = 2,
InitialClassValuesPosition = 3,
// Index of location where the class index offset value is located
SinglePropOffsetPositions = 4,
// Position of where the initial styles are stored in the styling context
// This index must align with HOST, see interfaces/view.ts
ElementPosition = 5,
ElementPosition = 0,
// Index of location where the start of single properties are stored. (`updateStyleProp`)
MasterFlagPosition = 1,
// Position of where the registered directives exist for this styling context
DirectiveRegistryPosition = 2,
// Position of where the initial styles are stored in the styling context
InitialStyleValuesPosition = 3,
InitialClassValuesPosition = 4,
// Index of location where the class index offset value is located
SinglePropOffsetPositions = 5,
// Position of where the last string-based CSS class value was stored (or a cached version of the
// initial styles when a [class] directive is present)
CachedMultiClasses = 6,