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".
This commit is contained in:
Eugen Wissner 2017-07-25 07:40:14 +02:00
parent a37c9b162e
commit 1389b03842

View File

@ -178,7 +178,7 @@ pure nothrow @safe @nogc
return (size - 1) / alignment * alignment + alignment; return (size - 1) / alignment * alignment + alignment;
} }
/** /*
* Internal function used to create, resize or destroy a dynamic array. It * Internal function used to create, resize or destroy a dynamic array. It
* may throw $(D_PSYMBOL OutOfMemoryError). The new * may throw $(D_PSYMBOL OutOfMemoryError). The new
* allocated part of the array isn't initialized. This function can be trusted * allocated part of the array isn't initialized. This function can be trusted
@ -381,10 +381,7 @@ in
} }
body body
{ {
T ret; auto mem = (() @trusted => allocator.allocate(stateSize!T))();
const size = stateSize!T;
auto mem = (() @trusted => allocator.allocate(size))();
if (mem is null) if (mem is null)
{ {
onOutOfMemoryError(); onOutOfMemoryError();
@ -394,9 +391,7 @@ body
() @trusted { allocator.deallocate(mem); }(); () @trusted { allocator.deallocate(mem); }();
} }
ret = emplace!T(mem[0 .. size], args); return emplace!T(mem[0 .. stateSize!T], args);
return ret;
} }
/** /**
@ -425,10 +420,7 @@ in
} }
body body
{ {
typeof(return) ret; auto mem = (() @trusted => allocator.allocate(stateSize!T))();
const size = stateSize!T;
auto mem = (() @trusted => allocator.allocate(size))();
if (mem is null) if (mem is null)
{ {
onOutOfMemoryError(); onOutOfMemoryError();
@ -438,10 +430,8 @@ body
() @trusted { allocator.deallocate(mem); }(); () @trusted { allocator.deallocate(mem); }();
} }
auto ptr = (() @trusted => (cast(T*) mem[0 .. size].ptr))(); auto ptr = (() @trusted => (cast(T*) mem[0 .. stateSize!T].ptr))();
ret = emplace!T(ptr, args); return emplace!T(ptr, args);
return ret;
} }
/// ///
@ -453,12 +443,12 @@ unittest
} }
/** /**
* Constructs a new array with $(D_PARAM size) elements. * Constructs a new array with $(D_PARAM n) elements.
* *
* Params: * Params:
* T = Array type. * T = Array type.
* allocator = Allocator. * allocator = Allocator.
* size = Array size. * n = Array size.
* *
* Returns: Newly created array. * Returns: Newly created array.
* *