[Issue 11335] Appender.reserve is overzealous and wrong

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Oct 23 18:33:05 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=11335



--- Comment #1 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-10-23 18:33:04 PDT ---
Quote from pull:

== 1 ==
Appender.reserve is overzealous. Given a request of a capacity of size, it
basically took the request, made that grow, and then reserved that. This
results in things like:

auto app = Appender!(int[]);
app.reserve(65_000);
writeln(app.capacity); //Prints abous 107_000 on my machine. Pointless.

== 2 ==
There was a little bug in reserve, where it called ensureAddable(requestedSize
- currentCapacity) as opposed to ensureAddable(requestedSize - currentSize).
This for example, things like this failed:

A case that failed:

Appender with 32_000 element, and 64_000 capacity.
Request 80_000 capacity
=> ensureAddable(48_000)
=> do nothing
=> resulting capacity is actually smaller than 80_000

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list