WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
211078
Improve performance of commonInclusiveAncestor for deeply nested nodes
https://bugs.webkit.org/show_bug.cgi?id=211078
Summary
Improve performance of commonInclusiveAncestor for deeply nested nodes
Darin Adler
Reported
2020-04-27 08:22:32 PDT
Improve performance of commonInclusiveAncestor for deeply nested nodes
Attachments
Patch
(2.14 KB, patch)
2020-04-27 08:24 PDT
,
Darin Adler
no flags
Details
Formatted Diff
Diff
Patch
(2.15 KB, patch)
2020-04-27 08:28 PDT
,
Darin Adler
no flags
Details
Formatted Diff
Diff
Patch
(2.16 KB, patch)
2020-04-27 08:39 PDT
,
Darin Adler
koivisto
: review+
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Darin Adler
Comment 1
2020-04-27 08:24:13 PDT
Comment hidden (obsolete)
Created
attachment 397684
[details]
Patch
Darin Adler
Comment 2
2020-04-27 08:26:08 PDT
Comment hidden (obsolete)
Comment on
attachment 397684
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=397684&action=review
> Source/WebCore/dom/Node.cpp:2631 > + for (std::size_t i = 0; i < difference; ++i)
I should omit the std:: here.
Darin Adler
Comment 3
2020-04-27 08:28:23 PDT
Comment hidden (obsolete)
Created
attachment 397685
[details]
Patch
Darin Adler
Comment 4
2020-04-27 08:39:19 PDT
Created
attachment 397686
[details]
Patch
Antti Koivisto
Comment 5
2020-04-27 09:06:16 PDT
Comment on
attachment 397686
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=397686&action=review
findNearestCommonComposedAncestor has another implementation using a HashSet. Yours is probably better since it avoids allocation and hashing even if it requires more traversal.
> Source/WebCore/dom/Node.cpp:2627 > + auto [depthA, depthB] = std::make_tuple(depth(a), depth(b)); > + auto [x, y, difference] = depthA > depthB
Interesting use of temporary tuples.
Antti Koivisto
Comment 6
2020-04-27 09:08:24 PDT
If a==b is common it might be worth optimizing for it.
Darin Adler
Comment 7
2020-04-27 09:18:31 PDT
(In reply to Antti Koivisto from
comment #6
)
> If a==b is common it might be worth optimizing for it.
Maybe I should speculatively include that without even measuring?
Antti Koivisto
Comment 8
2020-04-27 09:31:14 PDT
Yeah, it is such a cheap test.
Darin Adler
Comment 9
2020-04-27 09:45:39 PDT
Tempting to also add a special case for when a and b both have the same parent. But for now I will not.
Darin Adler
Comment 10
2020-04-27 09:47:28 PDT
Committed
r260762
: <
https://trac.webkit.org/changeset/260762
>
Radar WebKit Bug Importer
Comment 11
2020-04-27 09:48:15 PDT
<
rdar://problem/62456207
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug