fix appenderNewCapacity for curLen == 0, start with minimum of 8.

This commit is contained in:
Rainer Schuetze 2013-11-16 17:35:34 +01:00
parent 9741b28af2
commit cc548fe9cb

View file

@ -2454,6 +2454,8 @@ struct Appender(A : T[], T)
//ret sugLen: A suggested growth.
private size_t appenderNewCapacity(size_t TSizeOf)(size_t curLen, size_t reqLen) @safe pure nothrow
{
if(curLen == 0)
return max(reqLen,8);
ulong mult = 100 + (1000UL) / (bsr(curLen * TSizeOf) + 1);
// limit to doubling the length, we don't want to grow too much
if(mult > 200)