mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:27:45 +00:00
LibWeb: Add fast-paths for wrapping already-wrapped C++ objects
If a C++ object already has a JS wrapper, we don't need to go through the expensive type checks to figure out which kind of wrapper to create. Instead, just return the wrapper we already have! This gives a noticeable increase in smoothness on Acid3, where ~10% of CPU time was previously spent doing RTTI type checks in wrap(). With these changes, it's down to ~1%.
This commit is contained in:
parent
5c5e4b5ae5
commit
269f9c6863
3 changed files with 9 additions and 0 deletions
|
@ -14,6 +14,9 @@ namespace Web::Bindings {
|
|||
|
||||
CSSRuleWrapper* wrap(JS::GlobalObject& global_object, CSS::CSSRule& rule)
|
||||
{
|
||||
if (rule.wrapper())
|
||||
return static_cast<CSSRuleWrapper*>(rule.wrapper());
|
||||
|
||||
if (is<CSS::CSSStyleRule>(rule))
|
||||
return static_cast<CSSRuleWrapper*>(wrap_impl(global_object, verify_cast<CSS::CSSStyleRule>(rule)));
|
||||
return static_cast<CSSRuleWrapper*>(wrap_impl(global_object, rule));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue