D的双循环去分号.
string stripsemicolons(string s)
{
string result;
// prevent reallocations
result.length = s.length;
result.length = 0;
//append to string only when needed
size_t i = 0;
while (i < s.length)
{
size_t j = i;
while (i < s.length && s[i] != ';')
++i;
result ~= s[j..i];
}
}
浙公网安备 33010602011771号