Bug 23676 - Speed up uses of reserveCapacity on new vectors by adding a new reserveInitialCapacity
Summary: Speed up uses of reserveCapacity on new vectors by adding a new reserveInitia...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.5
: P2 Normal
Assignee: Darin Adler
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-01 18:11 PST by Darin Adler
Modified: 2009-02-02 16:28 PST (History)
2 users (show)

See Also:


Attachments
patch (20.72 KB, patch)
2009-02-01 18:27 PST, Darin Adler
hyatt: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Darin Adler 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.
Comment 1 Darin Adler 2009-02-01 18:27:16 PST
Created attachment 27239 [details]
patch
Comment 2 Dave Hyatt 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
Comment 3 Darin Adler 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.
Comment 4 Darin Adler 2009-02-02 16:28:01 PST
http://trac.webkit.org/changeset/40501