avoid quadratic case when appending style sheets
Categories
(Core :: CSS Parsing and Computation, defect)
Tracking
()
People
(Reporter: tnikkel, Assigned: tnikkel)
References
(Blocks 1 open bug)
Details
(Whiteboard: [sp3])
Attachments
(2 files)
Bug 1931789. Change DocumentOrShadowRoot::StyleOrderIndexOfSheet to return size_t. r?smaug,#dom-core
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review |
Assignee | ||
Comment 1•3 months ago
|
||
size_t is the return type of nsTArray::IndexOf. NoIndex is defined as (size_t)-1. Implicitly converting this to int32_t which is signed and might be a different bit width seems sketchy to me. This makes this clear and explicit.
Assignee | ||
Comment 2•3 months ago
|
||
FillStyleSetDocumentSheets specifically iterates the existing sheets in reverse order when calling AddDocStyleSheet in order to avoid this problem (because FindDocStyleSheetInsertionPoint iterates from the start of existing sheets).
FindDocStyleSheetInsertionPoint has to deal with some other types of sheets, so just flipping the order it iterates seems a bit more complex.
The slow case that we want to avoid here is the other caller of AddDocStyleSheet: AddStyleSheetToStyleSets. When the sheets are appended at the end one by one using this function we hit the quadratic worst case.
This is about 0.75% of the full sp3 suite.
Updated•2 months ago
|
Updated•2 months ago
|
Description
•