Skip to content

Commit

Permalink
fix small string and small array for betterC
Browse files Browse the repository at this point in the history
  • Loading branch information
9il committed Aug 2, 2020
1 parent 4418e9f commit 0a32920
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions source/mir/small_array.d
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,10 @@ struct SmallArray(T, uint maxLength)
ref typeof(this) append(T elem)
{
if (_length == maxLength)
throw exception;
{
version(D_Exceptions) throw exception;
else assert(0, errorMsg);
}
_data[_length++] = elem;
return this;
}
Expand All @@ -190,7 +193,10 @@ struct SmallArray(T, uint maxLength)
ref typeof(this) append(V[] array)
{
if (_length + array.length > maxLength)
throw exception;
{
version(D_Exceptions) throw exception;
else assert(0, errorMsg);
}
_data[_length .. _length + array.length] = array;
_length += array.length;
return this;
Expand Down
10 changes: 8 additions & 2 deletions source/mir/small_string.d
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,10 @@ extern(D):
{
auto length = asArray.length;
if (length == maxLength)
throw exception;
{
version(D_Exceptions) throw exception;
else assert(0, errorMsg);
}
_data[length] = c;
return this;
}
Expand All @@ -204,7 +207,10 @@ extern(D):
{
auto length = asArray.length;
if (length + str.length > maxLength)
throw exception;
{
version(D_Exceptions) throw exception;
else assert(0, errorMsg);
}
if (__ctfe)
_data[length .. str.length + length] = str;
else
Expand Down

0 comments on commit 0a32920

Please sign in to comment.