perf(ivy): remove renderStringify calls for text nodes creation (#32342)
Values passed to the `ɵɵtext` instruction are strings (or undefined) in the generated code so no need to stringify those again. PR Close #32342
This commit is contained in:
parent
fac066ea9f
commit
a1e91b00d2
|
@ -5,15 +5,13 @@
|
|||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import {assertDataInRange, assertDefined, assertEqual} from '../../util/assert';
|
||||
import {assertDataInRange, assertEqual} from '../../util/assert';
|
||||
import {TNodeType} from '../interfaces/node';
|
||||
import {RText, isProceduralRenderer} from '../interfaces/renderer';
|
||||
import {BINDING_INDEX, HEADER_OFFSET, LView, RENDERER, TVIEW, T_HOST} from '../interfaces/view';
|
||||
import {BINDING_INDEX, HEADER_OFFSET, RENDERER, TVIEW, T_HOST} from '../interfaces/view';
|
||||
import {appendChild, createTextNode} from '../node_manipulation';
|
||||
import {getLView, getSelectedIndex, setIsNotParent} from '../state';
|
||||
import {NO_CHANGE} from '../tokens';
|
||||
import {renderStringify} from '../util/misc_utils';
|
||||
import {getNativeByIndex} from '../util/view_utils';
|
||||
|
||||
import {bind} from './property';
|
||||
import {getOrCreateTNode, textBindingInternal} from './shared';
|
||||
|
@ -24,19 +22,17 @@ import {getOrCreateTNode, textBindingInternal} from './shared';
|
|||
* Create static text node
|
||||
*
|
||||
* @param index Index of the node in the data array
|
||||
* @param value Value to write. This value will be stringified.
|
||||
* @param value Static string value to write.
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵtext(index: number, value?: any): void {
|
||||
export function ɵɵtext(index: number, value: string = ''): void {
|
||||
const lView = getLView();
|
||||
ngDevMode && assertEqual(
|
||||
lView[BINDING_INDEX], lView[TVIEW].bindingStartIndex,
|
||||
'text nodes should be created before any bindings');
|
||||
ngDevMode && ngDevMode.rendererCreateTextNode++;
|
||||
ngDevMode && assertDataInRange(lView, index + HEADER_OFFSET);
|
||||
const textNative = lView[index + HEADER_OFFSET] = createTextNode(value, lView[RENDERER]);
|
||||
ngDevMode && ngDevMode.rendererSetText++;
|
||||
const tNode = getOrCreateTNode(lView[TVIEW], lView[T_HOST], index, TNodeType.Element, null, null);
|
||||
|
||||
// Text nodes are self closing.
|
||||
|
|
|
@ -20,7 +20,6 @@ import {ProceduralRenderer3, RElement, RNode, RText, Renderer3, isProceduralRend
|
|||
import {isLContainer, isLView, isRootView} from './interfaces/type_checks';
|
||||
import {CHILD_HEAD, CLEANUP, DECLARATION_LCONTAINER, FLAGS, HOST, HookData, LView, LViewFlags, NEXT, PARENT, QUERIES, RENDERER, TVIEW, T_HOST, unusedValueExportToPlacateAjd as unused5} from './interfaces/view';
|
||||
import {assertNodeOfPossibleTypes, assertNodeType} from './node_assert';
|
||||
import {renderStringify} from './util/misc_utils';
|
||||
import {findComponentView, getLViewParent} from './util/view_traversal_utils';
|
||||
import {getNativeByTNode, getNativeByTNodeOrNull, unwrapRNode} from './util/view_utils';
|
||||
|
||||
|
@ -116,9 +115,11 @@ function applyToElementOrContainer(
|
|||
}
|
||||
}
|
||||
|
||||
export function createTextNode(value: any, renderer: Renderer3): RText {
|
||||
return isProceduralRenderer(renderer) ? renderer.createText(renderStringify(value)) :
|
||||
renderer.createTextNode(renderStringify(value));
|
||||
export function createTextNode(value: string, renderer: Renderer3): RText {
|
||||
ngDevMode && ngDevMode.rendererCreateTextNode++;
|
||||
ngDevMode && ngDevMode.rendererSetText++;
|
||||
return isProceduralRenderer(renderer) ? renderer.createText(value) :
|
||||
renderer.createTextNode(value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1086,7 +1086,7 @@ export declare function ɵɵtemplate(index: number, templateFn: ComponentTemplat
|
|||
|
||||
export declare function ɵɵtemplateRefExtractor(tNode: TNode, currentView: LView): ViewEngine_TemplateRef<unknown> | null;
|
||||
|
||||
export declare function ɵɵtext(index: number, value?: any): void;
|
||||
export declare function ɵɵtext(index: number, value?: string): void;
|
||||
|
||||
export declare function ɵɵtextBinding<T>(value: T | NO_CHANGE): void;
|
||||
|
||||
|
|
Loading…
Reference in New Issue