www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11335] New: Appender.reserve is overzealous and wrong

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11335

           Summary: Appender.reserve is overzealous and wrong
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: pull
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: andrej.mitrovich gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-10-23
18:32:04 PDT ---


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 23 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11335



--- Comment #1 from Andrej Mitrovic <andrej.mitrovich 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: -------
Oct 23 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11335



--- Comment #2 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-10-23
18:33:12 PDT ---
https://github.com/D-Programming-Language/phobos/pull/1410

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 23 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11335


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #3 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-10-23
18:33:42 PDT ---
https://github.com/D-Programming-Language/phobos/commit/693ccb171def23bdca28e180bf1dbf30a7375a38

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