Closed
Bug 311458
Opened 19 years ago
Closed 19 years ago
Appending a single char to a string does a memcpy
Categories
(Core :: XPCOM, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 312681
People
(Reporter: bzbarsky, Unassigned)
References
(Blocks 1 open bug)
Details
(Keywords: perf)
It looks like we treat a single char as a length-one char buffer... would it possibly be faster to just assign to the right location instead of doing a memcpy (via char_traits::copy)?
Comment 1•19 years ago
|
||
Sure... do we have any data to prove that this may be worth the effort?
Comment 2•19 years ago
|
||
Where is this code? It sounds like it might be better for the CSS code to construct a local dependentconcatenation and then append it at once. Of course the dependentconcatenation code doesn't deal with single chars (perhaps a special single-char class could be arranged, I'm not very familiar with the internals there).
![]() |
Reporter | |
Comment 3•19 years ago
|
||
I was looking at a profile that does a bunch of canvas operations... setting the fill color looks like this (all numbers are hits under the method): 24020 nsCanvasRenderingContext2D::SetFillStyle(nsIVariant*) of which 14334 CSSParserImpl::ParseColorString of which 1365 nsSubstring::Replace That's about 10% of the total CSS parse time here. For general CSS it's a bit better, but not much -- still about 5%, as I recall. I'm not sure how much of this is bug 311456 though, so maybe we should fix that first...
Depends on: 311456
![]() |
Reporter | |
Comment 4•19 years ago
|
||
The code in question is nsCSSScanner::GatherIdent. Between pushback and character escapes, this might be nontrivial to do in a way that doesn't involve appending a char at a time.
Comment 5•19 years ago
|
||
So, you believe that a large portion of the cost is the memcpy call done by Replace? Enough to warrant an additional codepath in the string module?
![]() |
Reporter | |
Comment 6•19 years ago
|
||
OK, I dug about a bit, and it looks like nsSubstring::Replace breaks down as (1365 hits total): 529 hits in the function itself 612 hits under nsSubstring::ReplacePrep(unsigned, unsigned, unsigned) 190 hits under memcpy So yeah, memcpy doesn't seem to be a big deal here. I'll reprofile once we decide what we're doing with bug 311456, if anything.
![]() |
Reporter | |
Comment 7•19 years ago
|
||
Probably not really an issue, based on more profile-reading.
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → INVALID
![]() |
Reporter | |
Comment 8•19 years ago
|
||
Looks like this got fixed after all.
Status: RESOLVED → REOPENED
Resolution: INVALID → ---
![]() |
Reporter | |
Comment 9•19 years ago
|
||
*** This bug has been marked as a duplicate of 312681 ***
Status: REOPENED → RESOLVED
Closed: 19 years ago → 19 years ago
Resolution: --- → DUPLICATE
Assignee | ||
Updated•4 years ago
|
Component: String → XPCOM
You need to log in
before you can comment on or make changes to this bug.
Description
•