Skip to content

Commit

Permalink
Merge pull request #3517 from rainers/outbuffer_gccalls
Browse files Browse the repository at this point in the history
std.outbuffer: remove gratuitious calls into the GC
  • Loading branch information
dnadlinger committed Jul 29, 2015
2 parents dd838f1 + 13cb3de commit e308ff1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions std/outbuffer.d
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ private
* OutBuffer's byte order is the format native to the computer.
* To control the byte order (endianness), use a class derived
* from OutBuffer.
* OutBuffer's internal buffer is allocated with the GC.
* OutBuffer's internal buffer is allocated with the GC. Pointers
* stored into the buffer are scanned by the GC, but you have to
* ensure proper alignment, e.g. by using alignSize((void*).sizeof).
*/

class OutBuffer
Expand Down Expand Up @@ -80,8 +82,9 @@ class OutBuffer
//c.stdio.printf("OutBuffer.reserve: length = %d, offset = %d, nbytes = %d\n", data.length, offset, nbytes);
if (data.length < offset + nbytes)
{
data.length = (offset + nbytes) * 2;
GC.clrAttr(data.ptr, GC.BlkAttr.NO_SCAN);
void[] vdata = data;
vdata.length = (offset + nbytes + 7) * 2; // allocates as void[] to not set BlkAttr.NO_SCAN
data = cast(ubyte[])vdata;
}
}

Expand Down

0 comments on commit e308ff1

Please sign in to comment.