This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [Fwd: basic_string<> - useless because of its poor performance]


In article <20010706163002.A1722@alinoe.com>,
Carlo Wood <carlo@alinoe.com> writes:

> On Fri, Jul 06, 2001 at 02:35:19AM -0500, Loren James Rittle wrote:
>> +       // This version assumes the malloc implementation prefers to
>> +       // align allocations over the size of a page to a page boundary
>> +       // and under the size of a page to a power of 2.

> The comments are not consistant with the code.

Huh?  The comment explicitly states the *assumption* made about the
*malloc implementation* used while generating the sample capacity
round-up code.  It does not explicitly state how the code that follows
works.

(As far as I know, those assumptions only precisely match one
implementation of malloc in existence which is why I wanted to be
quite explicit in what I assumed)...

> It does not align to a power of 2 for small sizes, does it?

Correct, since small allocation sizes are handled by a special
allocator provided by our default STL configuration.

> It seems to align to a boundary of 256 bytes (256, 512, 768, 1024,
> 1280, ...) for sizes larger than 128 and not touch the size at all
> for sizes smaller or equal than 128.

Correct.

In any event, we now know that we must continue to round up capacity
to a power of 2 in order to meet the standard (from multiple sources).
And someone (maybe you ;-) posted a better way to hook in.

Anyone that finalizes the patch to go in should consider the points I
think I got right (which followed the exchange with Ulrich on
implementation header padding).  If no one beats me to it, then I
might be able to work on this next week.

Regards,
Loren


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]