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
102
102
else
103
103
{
104
104
auto it = result;
105
- foreach (ref f; r)
105
+ foreach (f; r)
106
106
{
107
- emplaceRef! E(it[0 ], f);
107
+ import mir.functional: forward;
108
+ emplaceRef! E(it[0 ], forward (f));
108
109
it = it[1 .. $];
109
110
}
110
111
}
@@ -114,18 +115,30 @@ if ((isInputRange!Range || isIterable!Range) && !isInfinite!Range && !isStaticAr
114
115
else
115
116
{
116
117
import mir.appender: ScopedBuffer;
117
- ScopedBuffer! E a;
118
+ ScopedBuffer! (Unqual ! E) a;
118
119
static if (isInputRange! Range )
119
120
for (; ! r.empty; r.popFront)
120
121
a.put(r.front);
121
122
else
122
123
static if (isPointer! Range )
124
+ {
125
+ import mir.functional: forward;
123
126
foreach (e; * r)
124
- a.put(e);
127
+ a.put(forward! e);
128
+ }
125
129
else
130
+ {
131
+ import mir.functional: forward;
126
132
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
+ })();
129
142
}
130
143
}
131
144
You can’t perform that action at this time.
0 commit comments