perf(compiler-vapor): combine effect
This commit is contained in:
parent
082b6c40b5
commit
8786c076d9
|
@ -328,14 +328,8 @@ export function render(_ctx) {
|
|||
_on(n4, "click", (...args) => (_ctx.handleClick && _ctx.handleClick(...args)))
|
||||
_effect(() => {
|
||||
_setText(n1, undefined, _ctx.count)
|
||||
})
|
||||
_effect(() => {
|
||||
_setText(n2, undefined, _ctx.count)
|
||||
})
|
||||
_effect(() => {
|
||||
_setText(n3, undefined, _ctx.count)
|
||||
})
|
||||
_effect(() => {
|
||||
_setAttr(n4, "id", undefined, _ctx.count)
|
||||
})
|
||||
return n0
|
||||
|
|
|
@ -113,11 +113,28 @@ function createRootContext(
|
|||
) {
|
||||
return this.registerOperation(...operations)
|
||||
}
|
||||
// TODO combine effects
|
||||
effect.push({
|
||||
expressions: expressions as IRExpression[],
|
||||
operations,
|
||||
})
|
||||
const existing = effect.find((e) =>
|
||||
isSameExpression(e.expressions, expressions as IRExpression[]),
|
||||
)
|
||||
if (existing) {
|
||||
existing.operations.push(...operations)
|
||||
} else {
|
||||
effect.push({
|
||||
expressions: expressions as IRExpression[],
|
||||
operations,
|
||||
})
|
||||
}
|
||||
|
||||
function isSameExpression(a: IRExpression[], b: IRExpression[]) {
|
||||
if (a.length !== b.length) return false
|
||||
return a.every(
|
||||
(exp, i) => identifyExpression(exp) === identifyExpression(b[i]),
|
||||
)
|
||||
}
|
||||
|
||||
function identifyExpression(exp: IRExpression) {
|
||||
return typeof exp === 'string' ? exp : exp.content
|
||||
}
|
||||
},
|
||||
|
||||
template: '',
|
||||
|
|
Loading…
Reference in New Issue