Bug 136957 - Minimize virtual function calls in MarkupAccumulator
Summary: Minimize virtual function calls in MarkupAccumulator
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-19 11:37 PDT by Chris Dumez
Modified: 2014-09-19 17:12 PDT (History)
3 users (show)

See Also:


Attachments
Patch (9.17 KB, patch)
2014-09-19 11:40 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (7.16 KB, patch)
2014-09-19 16:25 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2014-09-19 11:37:40 PDT
We can minimize the number of virtual function calls in MarkupAccumulator by:
- De-virtualizing MarkupAccumulator::appendString(), which is never overridden
- Having MarkupAccumulator::appendEndTag() take an Element in argument instead of a Node, as it only applies to Element. This will force callers to do the isElementNode() check *before* calling the virtual function, instead of calling appendEndTag() unconditionally and have it return early.
Comment 1 Chris Dumez 2014-09-19 11:40:33 PDT
Created attachment 238380 [details]
Patch
Comment 2 Benjamin Poulain 2014-09-19 13:19:38 PDT
Comment on attachment 238380 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=238380&action=review

> Source/WebCore/page/PageSerializer.cpp:109
> -    virtual void appendEndTag(const Node&) override;
> +    virtual void appendEndTag(const Element&) override;

Instead of adding isElementNode() everywhere, you could have:
inline void appendEndTag(Node& node) {
    if (node.isElementNode())
        appendEndTag(toElement(node));   
}
Comment 3 Chris Dumez 2014-09-19 16:25:30 PDT
Created attachment 238396 [details]
Patch
Comment 4 WebKit Commit Bot 2014-09-19 17:11:57 PDT
Comment on attachment 238396 [details]
Patch

Clearing flags on attachment: 238396

Committed r173783: <http://trac.webkit.org/changeset/173783>
Comment 5 WebKit Commit Bot 2014-09-19 17:12:04 PDT
All reviewed patches have been landed.  Closing bug.