Closed Bug 728255 Opened 12 years ago Closed 12 years ago

Replace nsLineBox::LastChild() calls with O(1) equivalents where possible

Categories

(Core :: Layout: Block and Inline, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla13

People

(Reporter: MatsPalmgren_bugz, Assigned: MatsPalmgren_bugz)

References

Details

(Keywords: perf, Whiteboard: [inbound])

Attachments

(1 file)

In general we don't need to use nsLineBox::LastChild(), which is O(n)
on the number of frames in the line, except for the last line of the
overflow lines list.

1. the last frame of the last normal line is the same as
   mFrames.LastChild() which is O(1)
2. for any line that isn't the last line, the next line's
   mFirstChild->GetPrevSibling() is our last frame, also O(1)
3. for the last overflow line we must still use nsLineBox::LastChild()
   (this looks like a rare case though)

These invariants holds except in very rare cases when splitting a line
and messing with the mFirstChild / mChildCount.  nsLineBox::LastChild()
probably isn't correct in those cases either.  Anyway, that shouldn't
be the case for the places I'm fixing.
Attached patch fixSplinter Review
Try run is green:
https://tbpl.mozilla.org/?tree=Try&rev=25542a0f20f3
Attachment #598256 - Flags: review?(bzbarsky)
Comment on attachment 598256 [details] [diff] [review]
fix

r=me
Attachment #598256 - Flags: review?(bzbarsky) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/aaed6b9c8952
Whiteboard: [inbound]
Target Milestone: --- → mozilla13
https://hg.mozilla.org/mozilla-central/rev/aaed6b9c8952
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Depends on: 983570
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: