--- Comment #11 from 2010-08-26 05:20:08 PDT ---
This is still full of dirty runtime calls and attempts to emulate half of
lifetime.d (though the worst part is commented).

Why doesn't it simply use the D standard way to re-allocate an array, and then
use array.capacity to see how much can be safely appended?

Something along the lines of:

private struct Data {
   T[] arr;
   size_t user_length;

Data _data;

void put(T item) {
   if (_data.user_length == arr.length) {
      size_t newcapacity = something larger than user_length;
   _data.arr[_data.user_length++] = item;

void reallocate(size_t newcapacity) {
   _data.arr.length = newcapacity;
   //include the data "overallocated" by the runtime into the array
   size_t realcap = _data.arr.capacity;
   _data.arr.length = realcap;

T[] data() {
   T[] arr = _data.arr[0.._data.user_length];
   _data = _data.init;
   return arr;

Or did I overlook something.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to