You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2ac41b2
Browse filesBrowse the repository at this point in the historyBrowse files
perf: add ES5-compatible cache for deep hierarchy method resolution
When the instance shortcut optimization cannot be applied (frozen/readonly
targets, Proxy objects, or when the instance already owns the property), every
dynamic method call previously re-entered _getInstFunc with repeated property
lookups on every invocation.
This change adds a per-instance resolved-function cache stored directly in the
existing instFuncTable object (keyed by className + funcName). Since
instFuncTable is created with objCreate(null) during construction and
Object.freeze is shallow, it remains writable even when the instance itself is
frozen. Subsequent calls to the same proxy for the same instance return the
cached function directly, eliminating the _getInstFunc overhead entirely.
Additionally, the prototype chain walk inside _getInstFunc is now guarded
behind the canAddInst check, avoiding unnecessary visited-array allocation
when the instance already owns the property.
Fully ES5 compatible - no WeakMap or other ES6+ APIs required.
Impact: Reduces per-call overhead from O(property lookups) to O(1) cache hit
for all cases where the shortcut optimization cannot be applied, particularly
benefiting deep inheritance hierarchies (10+ levels).
0 commit comments