Closed Bug 244475 Opened 20 years ago Closed 20 years ago

string optimization in HTMLContentSink::AddAttributes

Categories

(Core :: Layout, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: bryner, Assigned: bryner)

Details

(Keywords: perf)

Attachments

(1 file)

Because of the way shared string buffers work, HTMLContentSink::AddAttributes
isn't quite optimal in the way it does an atom lookup for attribute names.  In
particular, calling ToLowerCase on the shared buffer heap-allocates a new
(mutable) buffer, then lowercases the string in-place, then the string is copied
again (while being converted to UTF-8) into a stack buffer when do_GetAtom is
called.  In addition to this, dealing with the shared buffer incurs overhead
from doing an atomic increment on the buffer reference count (which is silly
since we know we'll need a mutable buffer).

I have a patch which does the UTF-8 conversion (into a mutable buffer) up-front,
which gets rid of the heap allocation, extra string copy, and atomic increment
overhead.  It seems to give a Tp win of about 1%.
Attached patch patchSplinter Review
Attachment #149181 - Flags: superreview?(bzbarsky)
Attachment #149181 - Flags: review?(bzbarsky)
Comment on attachment 149181 [details] [diff] [review]
patch

r+sr=bzbarsky; fix nsHTMLFragmentContentSink too, though?
Attachment #149181 - Flags: superreview?(bzbarsky)
Attachment #149181 - Flags: superreview+
Attachment #149181 - Flags: review?(bzbarsky)
Attachment #149181 - Flags: review+
checked in.
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: