Scanner using prefixBytes() for optimization.

This commit is contained in:
Ferdinand Majerech 2014-08-05 20:57:30 +02:00
parent 3b303f6e82
commit 57d936ed0f

View file

@ -1643,8 +1643,8 @@ final class Scanner
{ {
// Increase length as long as we see whitespace. // Increase length as long as we see whitespace.
size_t length = 0; size_t length = 0;
while(" \t"d.canFind(reader_.peek(length))) { ++length; } while(" \t"d.canFind(reader_.peekByte(length))) { ++length; }
auto whitespaces = reader_.prefix(length); auto whitespaces = reader_.prefixBytes(length);
// Can check the last byte without striding because '\0' is ASCII // Can check the last byte without striding because '\0' is ASCII
const c = reader_.peek(length); const c = reader_.peek(length);
@ -1805,7 +1805,8 @@ final class Scanner
// Get as many plain spaces as there are. // Get as many plain spaces as there are.
size_t length = 0; size_t length = 0;
while(reader_.peekByte(length) == ' ') { ++length; } while(reader_.peekByte(length) == ' ') { ++length; }
char[] whitespaces = reader_.get(length); char[] whitespaces = reader_.prefixBytes(length);
reader_.forward(length);
dchar c = reader_.peek(); dchar c = reader_.peek();
mixin FastCharSearch!" \n\r\u0085\u2028\u2029"d search; mixin FastCharSearch!" \n\r\u0085\u2028\u2029"d search;