Skip to content

Commit c856f43

Browse files
refactor(core): move the data store operation out of instructions (#61425)
The view data store operation is not an instruction and shouldn't be located in the instructions folder. PR Close #61425
1 parent 1a3351c commit c856f43

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

packages/core/src/render3/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ export {ComponentFactory, ComponentFactoryResolver, ComponentRef} from './compon
4444
export {ɵɵgetInheritedFactory} from './di';
4545
export {getLocaleId, setLocaleId} from './i18n/i18n_locale_id';
4646
export {
47-
store,
4847
ɵɵadvance,
4948
ɵɵattribute,
5049
ɵɵattributeInterpolate1,
@@ -220,6 +219,8 @@ export {ɵɵgetComponentDepsFactory} from './local_compilation';
220219
export {ɵsetClassDebugInfo} from './debug/set_debug_info';
221220
export {ɵɵreplaceMetadata} from './hmr';
222221

222+
export {store} from './util/view_utils';
223+
223224
export {
224225
ComponentDebugMetadata,
225226
ComponentDef,

packages/core/src/render3/instructions/let_declaration.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ import {TNodeType} from '../interfaces/node';
1212
import {HEADER_OFFSET} from '../interfaces/view';
1313
import {getContextLView, getLView, getSelectedIndex, getTView, setCurrentTNode} from '../state';
1414
import {getOrCreateTNode} from '../tnode_manipulation';
15-
import {load} from '../util/view_utils';
16-
import {store} from './storage';
15+
import {load, store} from '../util/view_utils';
1716

1817
/** Object that indicates the value of a `@let` declaration that hasn't been initialized yet. */
1918
const UNINITIALIZED_LET = {};

packages/core/src/render3/instructions/storage.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,6 @@ import {HEADER_OFFSET, LView, TView} from '../interfaces/view';
99
import {getContextLView} from '../state';
1010
import {load} from '../util/view_utils';
1111

12-
/** Store a value in the `data` at a given `index`. */
13-
export function store<T>(tView: TView, lView: LView, index: number, value: T): void {
14-
// We don't store any static data for local variables, so the first time
15-
// we see the template, we should store as null to avoid a sparse array
16-
if (index >= tView.data.length) {
17-
tView.data[index] = null;
18-
tView.blueprint[index] = null;
19-
}
20-
lView[index] = value;
21-
}
22-
2312
/**
2413
* Retrieves a local reference from the current contextViewData.
2514
*

packages/core/src/render3/pipe.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {Type} from '../interface/type';
1414
import {InjectorProfilerContext, setInjectorProfilerContext} from './debug/injector_profiler';
1515
import {getFactoryDef} from './definition_factory';
1616
import {NodeInjector, setIncludeViewProviders} from './di';
17-
import {store, ɵɵdirectiveInject} from './instructions/all';
17+
import {ɵɵdirectiveInject} from './instructions/all';
1818
import {isHostComponentStandalone} from './instructions/element_validation';
1919
import {PipeDef, PipeDefList} from './interfaces/definition';
2020
import {TTextNode} from './interfaces/node';
@@ -27,7 +27,7 @@ import {
2727
pureFunctionVInternal,
2828
} from './pure_function';
2929
import {getBindingRoot, getCurrentTNode, getLView, getTView} from './state';
30-
import {load} from './util/view_utils';
30+
import {load, store} from './util/view_utils';
3131

3232
/**
3333
* Create a pipe.

packages/core/src/render3/util/view_utils.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,17 @@ export function load<T>(view: LView | TData, index: number): T {
138138
return view[index];
139139
}
140140

141+
/** Store a value in the `data` at a given `index`. */
142+
export function store<T>(tView: TView, lView: LView, index: number, value: T): void {
143+
// We don't store any static data for local variables, so the first time
144+
// we see the template, we should store as null to avoid a sparse array
145+
if (index >= tView.data.length) {
146+
tView.data[index] = null;
147+
tView.blueprint[index] = null;
148+
}
149+
lView[index] = value;
150+
}
151+
141152
export function getComponentLViewByIndex(nodeIndex: number, hostView: LView): LView {
142153
// Could be an LView or an LContainer. If LContainer, unwrap to find LView.
143154
ngDevMode && assertIndexInRange(hostView, nodeIndex);

0 commit comments

Comments
 (0)