From 1389b03842ede1ea73d38f41e6575f1055dc0a83 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Tue, 25 Jul 2017 07:40:14 +0200 Subject: [PATCH] memory: Fix parameter name in the documentation Size parameter for "make" was renamed into n, but the function description wasn't fixed: size => n This commit also removes some redundant variables in "make". --- source/tanya/memory/package.d | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/source/tanya/memory/package.d b/source/tanya/memory/package.d index a9491fe..e6d1db8 100644 --- a/source/tanya/memory/package.d +++ b/source/tanya/memory/package.d @@ -178,7 +178,7 @@ pure nothrow @safe @nogc return (size - 1) / alignment * alignment + alignment; } -/** +/* * Internal function used to create, resize or destroy a dynamic array. It * may throw $(D_PSYMBOL OutOfMemoryError). The new * allocated part of the array isn't initialized. This function can be trusted @@ -381,10 +381,7 @@ in } body { - T ret; - const size = stateSize!T; - - auto mem = (() @trusted => allocator.allocate(size))(); + auto mem = (() @trusted => allocator.allocate(stateSize!T))(); if (mem is null) { onOutOfMemoryError(); @@ -394,9 +391,7 @@ body () @trusted { allocator.deallocate(mem); }(); } - ret = emplace!T(mem[0 .. size], args); - - return ret; + return emplace!T(mem[0 .. stateSize!T], args); } /** @@ -425,10 +420,7 @@ in } body { - typeof(return) ret; - const size = stateSize!T; - - auto mem = (() @trusted => allocator.allocate(size))(); + auto mem = (() @trusted => allocator.allocate(stateSize!T))(); if (mem is null) { onOutOfMemoryError(); @@ -438,10 +430,8 @@ body () @trusted { allocator.deallocate(mem); }(); } - auto ptr = (() @trusted => (cast(T*) mem[0 .. size].ptr))(); - ret = emplace!T(ptr, args); - - return ret; + auto ptr = (() @trusted => (cast(T*) mem[0 .. stateSize!T].ptr))(); + return emplace!T(ptr, args); } /// @@ -453,12 +443,12 @@ unittest } /** - * Constructs a new array with $(D_PARAM size) elements. + * Constructs a new array with $(D_PARAM n) elements. * * Params: * T = Array type. * allocator = Allocator. - * size = Array size. + * n = Array size. * * Returns: Newly created array. *