Bug 23676

Summary: Speed up uses of reserveCapacity on new vectors by adding a new reserveInitialCapacity
Product: WebKit Reporter: Darin Adler <darin>
Component: Web Template FrameworkAssignee: Darin Adler <darin>
Status: RESOLVED FIXED    
Severity: Normal CC: oliver, slewis
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Mac   
OS: OS X 10.5   
Attachments:
Description Flags
patch hyatt: review+

Darin Adler
Reported 2009-02-01 18:11:45 PST
In the parser, memcpy showed up on a profile, copying zero bytes when setting the initial capacity on the vector of attributes. This made me realize we could and should special-case the initial capacity setting to do less work and be more inline. Patch forthcoming.
Attachments
patch (20.72 KB, patch)
2009-02-01 18:27 PST, Darin Adler
hyatt: review+
Darin Adler
Comment 1 2009-02-01 18:27:16 PST
Dave Hyatt
Comment 2 2009-02-01 20:17:39 PST
Comment on attachment 27239 [details] patch I see a couple of cases where inline capacity could have just been used instead of wasting an extra call on reserveCapacity or reserveInitialCapacity. For example: textBuffer.reserveInitialCapacity(cMaxSegmentSize); Could you go through these changes and look for any that just used a fixed size constant all the time and convert them to use inline capacity instead? I think that would make those cases more readable and help make the intent of reserveInitialCapacity more clear. r=me
Darin Adler
Comment 3 2009-02-02 08:55:31 PST
(In reply to comment #2) > (From update of attachment 27239 [details] [review]) > I see a couple of cases where inline capacity could have just been used instead > of wasting an extra call on reserveCapacity or reserveInitialCapacity. For > example: > > textBuffer.reserveInitialCapacity(cMaxSegmentSize); > > Could you go through these changes and look for any that just used a fixed size > constant all the time and convert them to use inline capacity instead? I think > that would make those cases more readable and help make the intent of > reserveInitialCapacity more clear. I don't think inline capacity is always better; I'll look at the individual cases, but note that inline capacity means that the buffer can't be transferred to another object. For example, if you're planning to use String::adopt then inline capacity won't work.
Darin Adler
Comment 4 2009-02-02 16:28:01 PST
Note You need to log in before you can comment on or make changes to this bug.