parseNoGC can work with code points directly.

This commit is contained in:
Ferdinand Majerech 2014-07-29 01:55:43 +02:00
parent 6e1239fdac
commit cac25207f1

View file

@ -33,10 +33,15 @@ body
Target v = 0;
size_t atStart = true;
for (; !s.empty; s.popFront())
// We can safely foreach over individual code points.
// Even with UTF-8 any digit is ASCII and anything not ASCII (such as the start of
// a UTF-8 sequence) is not a digit.
foreach(i; 0 .. s.length)
{
uint c = s.front;
if (c < '0')
dchar c = s[i];
// We can just take a char instead of decoding because anything non-ASCII is not
// going to be a decodable digit, i.e. we will end at such a byte.
if (c < '0' || c >= 0x80)
break;
if (radix < 10)
{