Open Bug 1931789 Opened 3 months ago Updated 3 days ago

avoid quadratic case when appending style sheets

Categories

(Core :: CSS Parsing and Computation, defect)

defect

Tracking

()

People

(Reporter: tnikkel, Assigned: tnikkel)

References

(Blocks 1 open bug)

Details

(Whiteboard: [sp3])

Attachments

(2 files)

No description provided.

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.

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.

Whiteboard: [sp3]
Duplicate of this bug: 1945382
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: