Skip to content

Commit 0a32920

Browse files
committed
fix small string and small array for betterC
1 parent 4418e9f commit 0a32920

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

source/mir/small_array.d

+8-2
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,10 @@ struct SmallArray(T, uint maxLength)
181181
ref typeof(this) append(T elem)
182182
{
183183
if (_length == maxLength)
184-
throw exception;
184+
{
185+
version(D_Exceptions) throw exception;
186+
else assert(0, errorMsg);
187+
}
185188
_data[_length++] = elem;
186189
return this;
187190
}
@@ -190,7 +193,10 @@ struct SmallArray(T, uint maxLength)
190193
ref typeof(this) append(V[] array)
191194
{
192195
if (_length + array.length > maxLength)
193-
throw exception;
196+
{
197+
version(D_Exceptions) throw exception;
198+
else assert(0, errorMsg);
199+
}
194200
_data[_length .. _length + array.length] = array;
195201
_length += array.length;
196202
return this;

source/mir/small_string.d

+8-2
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,10 @@ extern(D):
194194
{
195195
auto length = asArray.length;
196196
if (length == maxLength)
197-
throw exception;
197+
{
198+
version(D_Exceptions) throw exception;
199+
else assert(0, errorMsg);
200+
}
198201
_data[length] = c;
199202
return this;
200203
}
@@ -204,7 +207,10 @@ extern(D):
204207
{
205208
auto length = asArray.length;
206209
if (length + str.length > maxLength)
207-
throw exception;
210+
{
211+
version(D_Exceptions) throw exception;
212+
else assert(0, errorMsg);
213+
}
208214
if (__ctfe)
209215
_data[length .. str.length + length] = str;
210216
else

0 commit comments

Comments
 (0)