Fix Vector.remove not destroying from the end copied elements

This commit is contained in:
Eugen Wissner 2017-01-04 20:37:55 +01:00
parent 67952dabdb
commit e27d0fe58c
2 changed files with 6 additions and 4 deletions

View File

@ -17,8 +17,8 @@ data structures and utilities that depend on the Garbage Collector in Phobos.
Tanya consists of the following packages: Tanya consists of the following packages:
* `async`: Event loop. * `async`: Event loop (epoll, kqueue and IOCP).
* `container`: Queue, Vector, Singly linked list. * `container`: Queue, Vector, Singly linked list, buffers.
* `crypto`: Work in progress TLS implementation. * `crypto`: Work in progress TLS implementation.
* `math`: Multiple precision integer and a set of functions. * `math`: Multiple precision integer and a set of functions.
* `memory`: Tools for manual memory management (allocator, reference counting, * `memory`: Tools for manual memory management (allocator, reference counting,

View File

@ -650,6 +650,8 @@ struct Vector(T)
* r = Range originally obtained from this vector. * r = Range originally obtained from this vector.
* *
* Returns: Elements in $(D_PARAM r) after removing. * Returns: Elements in $(D_PARAM r) after removing.
*
* Precondition: $(D_PARAM r) refers to a region of $(D_KEYWORD this).
*/ */
Range!T remove(Range!T r) @trusted Range!T remove(Range!T r) @trusted
in in
@ -663,7 +665,7 @@ struct Vector(T)
{ {
*a = *b; *a = *b;
} }
length_ -= r.length; length = length_ - r.length;
return r; return r;
} }
@ -790,7 +792,7 @@ struct Vector(T)
ref T opIndexAssign(ref T value, in size_t pos) @trusted ref T opIndexAssign(ref T value, in size_t pos) @trusted
in in
{ {
assert(length > pos); assert(length_ > pos);
} }
body body
{ {