Repository navigation
fix: collect the hooks and imports of the string form Bare renders for objects - #7944
benedikt-bartscher wants to merge 7 commits into
Conversation
[Medium impact] The PR appears safe to merge; the previous missing-import issue is fixed. Summary
The previous missing-import finding is fixed. No new actionable issues were found. Reviews (8) · Last reviewed commit: "Reach the components of a Bare's rendere..." · Reviewed by Greptile |
Merging this PR will degrade performance by 4.42%3 warnings
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
…those of the original var
Bare._get_vars, _render and render each rebuilt the rendered var, so a boolean or object Bare made a new to_string() var on every call (about four _get_vars calls per Bare in a page compile), and each new var missed the _get_all_var_data cache. The contents and rendered var now live in the base class's _vars_cache, which _clear_compile_caches and deepcopy already drop, keyed on the contents so a reassigned contents is rendered afresh. Per call, bool/object: _get_vars 2.9 us -> 0.16 us, render 4.6 us -> 0.77 us; string/literal _get_vars 246 ns -> 155 ns. A full page compile with 400 Bares (200 bool/object) goes from ~48 ms to ~45 ms (~42 ms before this PR, the rest being the rendered var's hooks and imports this PR now collects).
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
…sal, so their imports count too
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
Barerenders an object or boolean var throughto_string(), but_get_varsyields only the original var. Hooks and imports are collected from_get_vars, so when a var subclass overridesto_string()with an expression that needs a hook or an import the original var does not have, the page calls it without declaring it and fails in the browser:This PR renders through one
_rendered_contents()helper and also yields the rendered var from_get_varswhen it differs from the contents, so its hooks and imports reach the page. It dropsBare._get_all_imports:Component._get_importsalready collects the imports of every var_get_varsyields, and the override replaced each library's list with the original var's, which lost a name the string form imports from the same library. The defaultto_string()of objects and booleans needs neither, so output for existing apps is unchanged.The use case is translated data in the i18n PR (#6796): a mapping of locale to text whose string form picks the text for the active locale, so
rx.text(product.name)shows one language and follows a locale switch.