Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions std/internal/cstring.d
Original file line number Diff line number Diff line change
Expand Up @@ -218,17 +218,20 @@ private:

To* _ptr;
size_t _length; // length of the string

// the 'small string optimization'
version (unittest)
{
enum buffLength = 16 / To.sizeof; // smaller size to trigger reallocations
// smaller size to trigger reallocations. Padding is to account for
// unittest/non-unittest cross-compilation (to avoid corruption)
To[16 / To.sizeof] _buff;
To[(256 - 16) / To.sizeof] _unittest_pad;
}
else
{
enum buffLength = 256 / To.sizeof; // production size
To[256 / To.sizeof] _buff; // production size
}

To[buffLength] _buff; // the 'small string optimization'

static TempCStringBuffer trustedVoidInit() { TempCStringBuffer res = void; return res; }
}

Expand Down