From 30102f9e3a905024d98b3ce6009ca49e4a89b505 Mon Sep 17 00:00:00 2001 From: Martin Nowak Date: Sun, 14 Jan 2018 04:22:31 +0100 Subject: [PATCH] avoid Buffer type which creates a huge __initZ symbol --- source/vibe/core/net.d | 6 +++--- source/vibe/core/stream.d | 8 +++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/source/vibe/core/net.d b/source/vibe/core/net.d index e86855b..1bef7d7 100644 --- a/source/vibe/core/net.d +++ b/source/vibe/core/net.d @@ -658,10 +658,10 @@ mixin(tracer); if (isInputStream!InputStream) { import std.algorithm.comparison : min; + import vibe.internal.allocator : theAllocator, makeArray, dispose; - static struct Buffer { ubyte[64*1024 - 4*size_t.sizeof] bytes = void; } - scope bufferobj = new Buffer; // FIXME: use heap allocation - auto buffer = bufferobj.bytes[]; + scope buffer = () @trusted { return cast(ubyte[]) theAllocator.allocate(64*1024); }(); + scope (exit) () @trusted { theAllocator.dispose(buffer); }(); //logTrace("default write %d bytes, empty=%s", nbytes, stream.empty); if( nbytes == 0 ){ diff --git a/source/vibe/core/stream.d b/source/vibe/core/stream.d index d337af6..78d3d88 100644 --- a/source/vibe/core/stream.d +++ b/source/vibe/core/stream.d @@ -39,12 +39,10 @@ ulong pipe(InputStream, OutputStream)(InputStream source, OutputStream sink, ulo @blocking @trusted if (isOutputStream!OutputStream && isInputStream!InputStream) { - import vibe.internal.allocator : theAllocator, make, dispose; + import vibe.internal.allocator : theAllocator, makeArray, dispose; - static struct Buffer { ubyte[64*1024] bytes = void; } - auto bufferobj = theAllocator.make!Buffer(); - scope (exit) theAllocator.dispose(bufferobj); - auto buffer = bufferobj.bytes; + scope buffer = cast(ubyte[]) theAllocator.allocate(64*1024); + scope (exit) theAllocator.dispose(buffer); //logTrace("default write %d bytes, empty=%s", nbytes, stream.empty); ulong ret = 0;