File tree Expand file tree Collapse file tree 1 file changed +19
-6
lines changed Expand file tree Collapse file tree 1 file changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -102,9 +102,10 @@ if ((isInputRange!Range || isIterable!Range) && !isInfinite!Range && !isStaticAr
102102 else
103103 {
104104 auto it = result;
105- foreach (ref f; r)
105+ foreach (f; r)
106106 {
107- emplaceRef! E(it[0 ], f);
107+ import mir.functional: forward;
108+ emplaceRef! E(it[0 ], forward (f));
108109 it = it[1 .. $];
109110 }
110111 }
@@ -114,18 +115,30 @@ if ((isInputRange!Range || isIterable!Range) && !isInfinite!Range && !isStaticAr
114115 else
115116 {
116117 import mir.appender: ScopedBuffer;
117- ScopedBuffer! E a;
118+ ScopedBuffer! (Unqual ! E) a;
118119 static if (isInputRange! Range )
119120 for (; ! r.empty; r.popFront)
120121 a.put(r.front);
121122 else
122123 static if (isPointer! Range )
124+ {
125+ import mir.functional: forward;
123126 foreach (e; * r)
124- a.put(e);
127+ a.put(forward! e);
128+ }
125129 else
130+ {
131+ import mir.functional: forward;
126132 foreach (e; r)
127- a.put(e);
128- return .array(a.data);
133+ a.put(forward! e);
134+ }
135+
136+ return (() @trusted {
137+ import std.array : uninitializedArray;
138+ auto ret = uninitializedArray! (Unqual! E[])(a.length);
139+ a.moveDataAndEmplaceTo(ret);
140+ return ret;
141+ })();
129142 }
130143}
131144
You can’t perform that action at this time.
0 commit comments