Bug 209667 - Optimize frequently used Document::canAcceptChild
Summary: Optimize frequently used Document::canAcceptChild
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Minor
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-03-27 11:07 PDT by Eugene But
Modified: 2020-03-27 11:27 PDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eugene But 2020-03-27 11:07:57 PDT
This came up during the codereview here: https://bugs.webkit.org/show_bug.cgi?id=208311#c53

Darin Adler said:

"Can’t help noticing that this function is not written with efficiency in mind. The nodeType virtual function is pretty expensive and we call it 3 times!"

and

"this can be optimized for all the common cases to not call nodeType at all, using functions like isElementNode and isTextNode that are inline single bit checks. Only exotic cases would require calls to nodeType."
Comment 1 Darin Adler 2020-03-27 11:27:37 PDT
I do want to be a bit cautious about not complicating this to optimize it if there’s no evidence a faster version would make any practical difference. So maybe we shouldn’t do it even though I suggested it. Would be easy to do, though.