[IMP] app: add fast path for when component has no prop

This commit is contained in:
Géry Debongnie
2022-06-09 14:55:57 +02:00
committed by Sam Degueldre
parent d046913a01
commit 55ac43c1db
26 changed files with 548 additions and 541 deletions
+4 -2
View File
@@ -1181,7 +1181,9 @@ export class CodeGenerator {
id,
expr: `app.createComponent(${
ast.isDynamic ? null : expr
}, ${!ast.isDynamic}, ${!!ast.slots}, ${!!ast.dynamicProps})`,
}, ${!ast.isDynamic}, ${!!ast.slots}, ${!!ast.dynamicProps}, ${
!ast.props && !ast.dynamicProps
})`,
});
let blockExpr = `${id}(${propString}, ${keyArg}, node, ctx, ${ast.isDynamic ? expr : null})`;
@@ -1278,7 +1280,7 @@ export class CodeGenerator {
let id = generateId("comp");
this.staticDefs.push({
id,
expr: `app.createComponent(null, false, true, false)`,
expr: `app.createComponent(null, false, true, false, false)`,
});
const target = compileExpr(ast.target);
+7 -2
View File
@@ -118,7 +118,8 @@ export class App<
name: string | null,
isStatic: boolean,
hasSlotsProp: boolean,
hasDynamicPropList: boolean
hasDynamicPropList: boolean,
hasNoProp: boolean
) {
const isDynamic = !isStatic;
function _arePropsDifferent(props1: Props, props2: Props): boolean {
@@ -129,7 +130,11 @@ export class App<
}
return hasDynamicPropList && Object.keys(props1).length !== Object.keys(props2).length;
}
const arePropsDifferent = hasSlotsProp ? () => true : _arePropsDifferent;
const arePropsDifferent = hasSlotsProp
? (_1: any, _2: any) => true
: hasNoProp
? (_1: any, _2: any) => false
: _arePropsDifferent;
const updateAndRender = ComponentNode.prototype.updateAndRender;
const initiateRender = ComponentNode.prototype.initiateRender;