WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
285160
Improve DOMStringList::contains() from O(n) to O(1)
https://bugs.webkit.org/show_bug.cgi?id=285160
Summary
Improve DOMStringList::contains() from O(n) to O(1)
Karl Dubost
Reported
2024-12-25 20:40:18 PST
https://searchfox.org/wubkat/rev/36d40c7dfd972e688c9c0febea6821825a85d6ac/Source/WebCore/dom/DOMStringList.cpp#38-48
```cpp bool DOMStringList::contains(const String& string) const { // FIXME: Currently, all consumers of DOMStringList store fairly small lists and thus an O(n) // algorithm is OK. But this may need to be optimized if larger amounts of data are // stored in m_strings. for (auto& value : m_strings) { if (value == string) return true; } return false; } ```
Attachments
Add attachment
proposed patch, testcase, etc.
Karl Dubost
Comment 1
2024-12-25 20:44:59 PST
It should be possible to initialize an unordered_string with all the strings and making it private. if (!m_stringSet) { m_stringSet.emplace(m_strings.begin(), m_strings.end()); } Then the contains function could return a result with m_stringSet->find(string) != m_stringSet->end();
Radar WebKit Bug Importer
Comment 2
2025-01-01 20:41:13 PST
<
rdar://problem/142250869
>
Alexsander Borges Damaceno
Comment 3
2025-01-03 20:56:26 PST
Pull request:
https://github.com/WebKit/WebKit/pull/38526
EWS
Comment 4
2025-02-03 22:43:19 PST
Committed
289769@main
(c430a96674ce): <
https://commits.webkit.org/289769@main
> Reviewed commits have been landed. Closing PR #38526 and removing active labels.
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