perf(ivy): remove unused argument in hostBindings function (#34969)
We had some logic for generating and passing in the `elIndex` parameter into the `hostBindings` function, but it wasn't actually being used for anything. The only place left that had a reference to it was the `StylingBuilder` and it only stored it without referencing it again. PR Close #34969
This commit is contained in:

committed by
Andrew Kushnir

parent
7069a83727
commit
304584c291
@ -245,7 +245,7 @@ export function createRootComponent<T>(
|
||||
addHostBindingsToExpandoInstructions(rootTView, componentDef);
|
||||
growHostVarsSpace(rootTView, rootLView, componentDef.hostVars);
|
||||
|
||||
invokeHostBindingsInCreationMode(componentDef, component, rootTNode);
|
||||
invokeHostBindingsInCreationMode(componentDef, component);
|
||||
}
|
||||
return component;
|
||||
}
|
||||
|
@ -172,9 +172,9 @@ function inheritHostBindings(
|
||||
definition: WritableDef, superHostBindings: HostBindingsFunction<any>) {
|
||||
const prevHostBindings = definition.hostBindings;
|
||||
if (prevHostBindings) {
|
||||
definition.hostBindings = (rf: RenderFlags, ctx: any, elementIndex: number) => {
|
||||
superHostBindings(rf, ctx, elementIndex);
|
||||
prevHostBindings(rf, ctx, elementIndex);
|
||||
definition.hostBindings = (rf: RenderFlags, ctx: any) => {
|
||||
superHostBindings(rf, ctx);
|
||||
prevHostBindings(rf, ctx);
|
||||
};
|
||||
} else {
|
||||
definition.hostBindings = superHostBindings;
|
||||
|
@ -100,7 +100,7 @@ export function setHostBindingsByExecutingExpandoInstructions(tView: TView, lVie
|
||||
if (instruction !== null) {
|
||||
setBindingRootForHostBindings(bindingRootIndex);
|
||||
const hostCtx = lView[currentDirectiveIndex];
|
||||
instruction(RenderFlags.Update, hostCtx, currentElementIndex);
|
||||
instruction(RenderFlags.Update, hostCtx);
|
||||
}
|
||||
// TODO(misko): PERF Relying on incrementing the `currentDirectiveIndex` here is
|
||||
// sub-optimal. The implications are that if we have a lot of directives but none of them
|
||||
@ -1266,7 +1266,7 @@ function invokeDirectivesHostBindings(tView: TView, lView: LView, tNode: TNode)
|
||||
const def = tView.data[i] as DirectiveDef<any>;
|
||||
const directive = lView[i];
|
||||
if (def.hostBindings !== null || def.hostVars !== 0 || def.hostAttrs !== null) {
|
||||
invokeHostBindingsInCreationMode(def, directive, tNode);
|
||||
invokeHostBindingsInCreationMode(def, directive);
|
||||
} else if (firstCreatePass) {
|
||||
expando.push(null);
|
||||
}
|
||||
@ -1281,13 +1281,10 @@ function invokeDirectivesHostBindings(tView: TView, lView: LView, tNode: TNode)
|
||||
*
|
||||
* @param def `DirectiveDef` which may contain the `hostBindings` function.
|
||||
* @param directive Instance of directive.
|
||||
* @param tNode Associated `TNode`.
|
||||
*/
|
||||
export function invokeHostBindingsInCreationMode(
|
||||
def: DirectiveDef<any>, directive: any, tNode: TNode) {
|
||||
export function invokeHostBindingsInCreationMode(def: DirectiveDef<any>, directive: any) {
|
||||
if (def.hostBindings !== null) {
|
||||
const elementIndex = tNode.index - HEADER_OFFSET;
|
||||
def.hostBindings !(RenderFlags.Create, directive, elementIndex);
|
||||
def.hostBindings !(RenderFlags.Create, directive);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -443,8 +443,7 @@ export type DirectiveTypeList =
|
||||
(DirectiveType<any>| ComponentType<any>|
|
||||
Type<any>/* Type as workaround for: Microsoft/TypeScript/issues/4881 */)[];
|
||||
|
||||
export type HostBindingsFunction<T> =
|
||||
<U extends T>(rf: RenderFlags, ctx: U, elementIndex: number) => void;
|
||||
export type HostBindingsFunction<T> = <U extends T>(rf: RenderFlags, ctx: U) => void;
|
||||
|
||||
/**
|
||||
* Type used for PipeDefs on component definition.
|
||||
|
Reference in New Issue
Block a user