Skip to content

Commit

Permalink
In the future Vec!T buffer will have alignment 1. This is because thi…
Browse files Browse the repository at this point in the history
…s is a rarely used feature that almost never wins against a merged allocation anyway, and often underperforms malloc. It also ties Vec to our alignedMalloc implementation, which ought to be removed eventually in favor of intel-intrinsics _mm_realloc and friends.
  • Loading branch information
Guillaume Piolat committed Dec 12, 2024
1 parent 35ef8b3 commit 4ea18a1
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions core/dplug/core/vec.d
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,13 @@ unittest


/// Returns: A newly created `Vec`.
Vec!T makeVec(T)(size_t initialSize = 0, int alignment = 1) nothrow @nogc
Vec!T makeVec(T)(size_t initialSize = 0) nothrow @nogc
{
return Vec!T(initialSize);
}

deprecated("Vec!T must have alignment 1. This constructor will be removed in Dplug v16")
Vec!T makeVec(T)(size_t initialSize = 0, int alignment) nothrow @nogc
{
return Vec!T(initialSize, alignment);
}
Expand All @@ -374,7 +380,17 @@ nothrow:
public
{
/// Creates an aligned buffer with given initial size.
this(size_t initialSize, int alignment) @safe
this(size_t initialSize) @safe
{
_size = 0;
_allocated = 0;
_data = null;
_alignment = 1;
resizeExactly(initialSize);
}

deprecated("Vec!T must have alignment 1. This constructor will be removed in Dplug v16")
this(size_t initialSize, int alignment) @safe
{
assert(alignment != 0);
_size = 0;
Expand Down

0 comments on commit 4ea18a1

Please sign in to comment.