aboutsummaryrefslogtreecommitdiff
path: root/source/tanya/memory/package.d
diff options
context:
space:
mode:
Diffstat (limited to 'source/tanya/memory/package.d')
-rw-r--r--source/tanya/memory/package.d31
1 files changed, 9 insertions, 22 deletions
diff --git a/source/tanya/memory/package.d b/source/tanya/memory/package.d
index 1959dbd..0595073 100644
--- a/source/tanya/memory/package.d
+++ b/source/tanya/memory/package.d
@@ -137,7 +137,8 @@ template stateSize(T)
*
* Returns: Aligned size.
*/
-size_t alignedSize(in size_t size, in size_t alignment = 8) pure nothrow @safe @nogc
+size_t alignedSize(const size_t size, const size_t alignment = 8)
+pure nothrow @safe @nogc
{
return (size - 1) / alignment * alignment + alignment;
}
@@ -145,31 +146,24 @@ size_t alignedSize(in size_t size, in size_t alignment = 8) pure nothrow @safe @
/**
* Internal function used to create, resize or destroy a dynamic array. It
* may throw $(D_PSYMBOL OutOfMemoryError). The new
- * allocated part of the array is initialized only if $(D_PARAM Init)
- * is set. This function can be trusted only in the data structures that
- * can ensure that the array is allocated/rellocated/deallocated with the
- * same allocator.
+ * allocated part of the array isn't initialized. This function can be trusted
+ * only in the data structures that can ensure that the array is
+ * allocated/rellocated/deallocated with the same allocator.
*
* Params:
* T = Element type of the array being created.
- * Init = If should be initialized.
* allocator = The allocator used for getting memory.
* array = A reference to the array being changed.
* length = New array length.
*
* Returns: $(D_PARAM array).
*/
-package(tanya) T[] resize(T,
- bool Init = true)
- (shared Allocator allocator,
- auto ref T[] array,
- const size_t length) @trusted
+package(tanya) T[] resize(T)(shared Allocator allocator,
+ auto ref T[] array,
+ const size_t length) @trusted
{
void[] buf = array;
- static if (Init)
- {
- const oldLength = array.length;
- }
+
if (!allocator.reallocate(buf, length * T.sizeof))
{
onOutOfMemoryError;
@@ -177,13 +171,6 @@ package(tanya) T[] resize(T,
// Casting from void[] is unsafe, but we know we cast to the original type.
array = cast(T[]) buf;
- static if (Init)
- {
- if (oldLength < length)
- {
- array[oldLength .. $] = T.init;
- }
- }
return array;
}