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; Target v = 0;
size_t atStart = true; 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; dchar c = s[i];
if (c < '0') // 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; break;
if (radix < 10) if (radix < 10)
{ {