Skip to content

Commit d29b10b

Browse files
committed
reduce void initialisations
1 parent f30ccd9 commit d29b10b

File tree

6 files changed

+16
-12
lines changed

6 files changed

+16
-12
lines changed

source/mir/appender.d

+5-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ struct ScopedBuffer(T, size_t bytes = 4096)
3333
private enum size_t _bufferLength = bytes / T.sizeof + (bytes % T.sizeof != 0);
3434
private T[] _buffer;
3535
private size_t _currentLength;
36-
private align(T.alignof) ubyte[_bufferLength * T.sizeof] _scopeBufferPayload = void;
36+
37+
version (mir_secure_memory)
38+
private align(T.alignof) ubyte[_bufferLength * T.sizeof] _scopeBufferPayload;
39+
else
40+
private align(T.alignof) ubyte[_bufferLength * T.sizeof] _scopeBufferPayload = void;
3741

3842
private ref inout(T[_bufferLength]) _scopeBuffer() inout @trusted scope
3943
{

source/mir/interpolate/constant.d

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ extern(D):
161161
auto opCall(X...)(in X xs) scope const @trusted
162162
if (X.length == N)
163163
{
164-
size_t[N] indexes = void;
164+
size_t[N] indexes;
165165
foreach(i; Iota!N)
166166
{
167167
static if (isInterval!(typeof(xs[i])))

source/mir/interpolate/linear.d

+3-3
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,8 @@ struct Linear(F, size_t N = 1, X = F)
265265
import mir.ndslice.topology: iota;
266266
alias Kernel = AliasCall!(LinearKernel!F, "opCall", derivative);
267267

268-
size_t[N] indexes = void;
269-
Kernel[N] kernels = void;
268+
size_t[N] indexes;
269+
Kernel[N] kernels;
270270

271271
enum rp2d = derivative;
272272

@@ -285,7 +285,7 @@ struct Linear(F, size_t N = 1, X = F)
285285
kernels[i] = LinearKernel!F(_grid[i][indexes[i]], _grid[i][indexes[i] + 1], x);
286286
}
287287

288-
align(64) F[2 ^^ N][derivative + 1] local = void;
288+
align(64) F[2 ^^ N][derivative + 1] local;
289289
immutable strides = _data._lengths.iota.strides;
290290

291291
void load(sizediff_t i)(F* from, F* to)

source/mir/interpolate/package.d

+1-1
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ auto vectorize(Kernel, F, size_t N, size_t R)(ref Kernel kernel, ref F[N] a, ref
577577
// }
578578
// else
579579
// {
580-
F[N][R] _c = void;//Temporary array in case "c" overlaps "a" and/or "b".
580+
F[N][R] _c;//Temporary array in case "c" overlaps "a" and/or "b".
581581
foreach(i; Iota!N)
582582
{
583583
auto r = kernel(a[i], b[i]);

source/mir/interpolate/spline.d

+3-3
Original file line numberDiff line numberDiff line change
@@ -805,8 +805,8 @@ struct Spline(F, size_t N = 1, X = F)
805805
alias Kernel = AliasCall!(SplineKernel!F, "opCall", derivative);
806806
enum rp2d = derivative == 3 ? 2 : derivative;
807807

808-
size_t[N] indexes = void;
809-
Kernel[N] kernels = void;
808+
size_t[N] indexes;
809+
Kernel[N] kernels;
810810

811811
foreach(i; Iota!N)
812812
{
@@ -823,7 +823,7 @@ struct Spline(F, size_t N = 1, X = F)
823823
kernels[i] = SplineKernel!F(_grid[i][indexes[i]], _grid[i][indexes[i] + 1], x);
824824
}
825825

826-
align(64) F[2 ^^ N * 2 ^^ N][2] local = void;
826+
align(64) F[2 ^^ N * 2 ^^ N][2] local;
827827

828828
void load(sizediff_t i)(const(F[2 ^^ N])* from, F[2 ^^ N]* to)
829829
{

source/mir/ndslice/connect/cpython.d

+3-3
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ version(mir_test) unittest
8080
import mir.ndslice.slice: Slice;
8181
auto bar(ref const Py_buffer view)
8282
{
83-
Slice!(const(double)*, 2) mat = void;
83+
Slice!(const(double)*, 2) mat;
8484
if (auto error = mat.fromPythonBuffer(view))
8585
{
86-
mat = mat.init; // has null pointer
86+
// has null pointer
8787
}
8888
return mat;
8989
}
@@ -224,7 +224,7 @@ version(mir_test) unittest
224224
auto structurePtr = cast(Structure!N*) Structure!N.sizeof.malloc;
225225
if (!structurePtr)
226226
assert(0);
227-
Py_buffer view = void;
227+
Py_buffer view;
228228

229229
if (auto error = slice.toPythonBuffer(view, PyBuf_records_ro, *structurePtr))
230230
{

0 commit comments

Comments
 (0)