It just needs a test for empty string.
Code: Select all
if ( size == 0 )
return;
Code: Select all
void remove(const string<T,TAlloc> toRemove)
{
u32 size = toRemove.size();
if ( size == 0 )
return;
u32 pos = 0;
u32 found = 0;
for (u32 i=0; i<used; ++i)
{
u32 j = 0;
while (j < size)
{
if (array[i + j] != toRemove[j])
break;
++j;
}
if (j == size)
{
found += size;
i += size - 1;
continue;
}
array[pos++] = array[i];
}
used -= found;
array[used] = 0;
}
Code: Select all
i += size - 1;