Moved a branch outside of aloop in scanPlain() to improve performance.
This commit is contained in:
parent
57d936ed0f
commit
d505728824
|
@ -1739,16 +1739,28 @@ final class Scanner
|
||||||
while(reader_.peekByte() != '#')
|
while(reader_.peekByte() != '#')
|
||||||
{
|
{
|
||||||
// Scan the entire plain scalar.
|
// Scan the entire plain scalar.
|
||||||
uint length = 0;
|
size_t length = 0;
|
||||||
dchar c;
|
dchar c = void;
|
||||||
for(;;)
|
// Moved the if() out of the loop for optimization.
|
||||||
|
if(flowLevel_ == 0)
|
||||||
{
|
{
|
||||||
c = reader_.peek(length);
|
c = reader_.peek(length);
|
||||||
const bool done = search.canFind(c) || (flowLevel_ == 0 && c == ':' &&
|
for(;;)
|
||||||
search.canFind(reader_.peek(length + 1))) ||
|
{
|
||||||
(flowLevel_ > 0 && ",:?[]{}"d.canFind(c));
|
const cNext = reader_.peek(length + 1);
|
||||||
if(done) { break; }
|
if(search.canFind(c) || (c == ':' && search.canFind(cNext))) { break; }
|
||||||
++length;
|
++length;
|
||||||
|
c = cNext;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
c = reader_.peek(length);
|
||||||
|
if(search.canFind(c) || ",:?[]{}"d.canFind(c)) { break; }
|
||||||
|
++length;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// It's not clear what we should do with ':' in the flow context.
|
// It's not clear what we should do with ':' in the flow context.
|
||||||
|
|
Loading…
Reference in a new issue