File tree Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,11 @@ import mir.conv: _mir_destroy = xdestroy;
1212private extern (C) @system nothrow @nogc pure void * memcpy(scope void * s1, scope const void * s2, size_t n);
1313
1414
15- // /
15+ /+ +
16+ The buffer uses stack memory and C Runtime to allocate temporal memory.
17+
18+ Shouldn't store references to GC allocated data.
19+ +/
1620struct ScopedBuffer (T, size_t bytes = 4096 )
1721 if (bytes && T.sizeof <= bytes)
1822{
Original file line number Diff line number Diff line change @@ -112,10 +112,9 @@ if ((isInputRange!Range || isIterable!Range) && !isInfinite!Range && !__traits(i
112112 }
113113 else
114114 {
115- import mir.appender: scopedBuffer;
116- import std.array : uninitializedArray;
115+ import std.array : std_appender = appender;
117116
118- auto a = scopedBuffer ! (Unqual ! E );
117+ auto a = std_appender ! (E[] );
119118
120119 static if (isInputRange! Range )
121120 for (; ! r.empty; r.popFront)
@@ -131,12 +130,7 @@ if ((isInputRange!Range || isIterable!Range) && !isInfinite!Range && !__traits(i
131130 foreach (e; r)
132131 a.put(forward! e);
133132 }
134-
135- return () @trusted {
136- auto ret = uninitializedArray! (Unqual! E[])(a.length);
137- a.moveDataAndEmplaceTo(ret);
138- return ret;
139- } ();
133+ return a.data;
140134 }
141135}
142136
You can’t perform that action at this time.
0 commit comments