[Webkit-unassigned] [Bug 53564] canHaveChildrenForEditing should be more efficient

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Feb 2 11:54:12 PST 2011


https://bugs.webkit.org/show_bug.cgi?id=53564





--- Comment #2 from Ryosuke Niwa <rniwa at webkit.org>  2011-02-02 11:54:11 PST ---
It seems like using hashset slows down the function.  I tried the following implementation:

bool canHaveChildrenForEditing(const Node* node)
{
    if (node->isTextNode() || !node->isElementNode())
        return false;

    DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, tagNames, ());
    if (tagNames.isEmpty()) {
        tagNames.add(hrTag);
        tagNames.add(brTag);
        tagNames.add(imgTag);
        tagNames.add(buttonTag);
        tagNames.add(inputTag);
        tagNames.add(textareaTag);
        tagNames.add(objectTag);
        tagNames.add(iframeTag);
        tagNames.add(appletTag);
        tagNames.add(datagridTag);
#if ENABLE(WML)
        tagNames.add(WMLNames::doTag);
#endif
    }

    return !tagNames.contains(static_cast<const Element*>(node)->tagQName());
}

but this implementation was consistently slower 14-5s vs. 16-17s to run LayoutTests/editing/selection/extend-selection-*.html with --repeat 5.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list