Skip to content

Commit 4418e9f

Browse files
committed
fix small string
1 parent d4dbde5 commit 4418e9f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

source/mir/small_string.d

+3-3
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ extern(D):
109109
version(D_Exceptions) throw exception;
110110
else assert(0, errorMsg);
111111
}
112-
_data = '\0';
113112
if (__ctfe)
114-
(cast(char[])_data)[0 .. str.length] = cast(char[]) str;
113+
_data[0 .. str.length] = str;
115114
else
116115
memcpy(_data.ptr, str.ptr, str.length);
116+
_data[str.length .. $] = '\0';
117117
return this;
118118
}
119119

@@ -184,7 +184,7 @@ extern(D):
184184
{
185185
_data = '\0';
186186
if (__ctfe)
187-
(cast(char[])_data)[0 .. str.length] = cast(char[]) str;
187+
_data[0 .. str.length] = str;
188188
else
189189
memcpy(_data.ptr, str.ptr, str.length);
190190
}

0 commit comments

Comments
 (0)