Bug 136957

Summary: Minimize virtual function calls in MarkupAccumulator
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: DOMAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, commit-queue, rniwa
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch none

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.