mirror of https://github.com/sveltejs/svelte
perf: hoist rest_props exclude list as a module-scope Set (#18252)
The compiler emitted an inline string array as the second argument to `$.rest_props(...)`, and the runtime did a linear `Array.prototype.includes` on it on every property access via the rest-props Proxy. The exclude list only depends on the component definition, not on the instance, so it can be hoisted to module scope and shared by every instance. Switching it to a `Set` at the same time makes each lookup O(1). For a component like `<Button ...rest />` rendered N times, this turns one per-instance allocation (plus a linear search on every rest-prop access) into one module-scope allocation plus O(1) lookups. The legacy `$$restProps` path is unchanged — it mutates the exclude list in its `deleteProperty` trap, so it can't share a hoisted Set across instances. --------- Co-authored-by: Rich Harris <rich.harris@vercel.com>pull/18322/head
parent
980c7e2321
commit
a40c745fd9
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
perf: hoist `rest_props` exclude list as a module-scope `Set`
|
||||
Loading…
Reference in new issue