undo some false optimizations
This commit is contained in:
parent
50372b194a
commit
b61d04303e
|
@ -1362,28 +1362,9 @@ struct Scanner
|
||||||
dchar c = reader_.peek();
|
dchar c = reader_.peek();
|
||||||
|
|
||||||
size_t numCodePoints;
|
size_t numCodePoints;
|
||||||
// This is an optimized way of writing:
|
while(!reader_.peek(numCodePoints).isFlowScalarBreakSpace) { ++numCodePoints; }
|
||||||
// while(!search.canFind(reader_.peek(numCodePoints))) { ++numCodePoints; }
|
|
||||||
outer: for(size_t oldSliceLength;;)
|
|
||||||
{
|
|
||||||
// This will not necessarily make slice 32 chars longer, as not all
|
|
||||||
// code points are 1 char.
|
|
||||||
const char[] slice = reader_.slice(numCodePoints + 32);
|
|
||||||
enforce(slice.length != oldSliceLength,
|
|
||||||
new ScannerException("While reading a flow scalar", startMark,
|
|
||||||
"reached end of file", reader_.mark));
|
|
||||||
|
|
||||||
for(size_t i = oldSliceLength; i < slice.length;)
|
if (numCodePoints > 0) { reader_.sliceBuilder.write(reader_.get(numCodePoints)); }
|
||||||
{
|
|
||||||
// slice is UTF-8 - need to decode
|
|
||||||
const ch = slice[i] < 0x80 ? slice[i++] : decode(slice, i);
|
|
||||||
if(ch.isFlowScalarBreakSpace) { break outer; }
|
|
||||||
++numCodePoints;
|
|
||||||
}
|
|
||||||
oldSliceLength = slice.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
reader_.sliceBuilder.write(reader_.get(numCodePoints));
|
|
||||||
|
|
||||||
c = reader_.peek();
|
c = reader_.peek();
|
||||||
if(quotes == ScalarStyle.singleQuoted && c == '\'' && reader_.peek(1) == '\'')
|
if(quotes == ScalarStyle.singleQuoted && c == '\'' && reader_.peek(1) == '\'')
|
||||||
|
@ -1540,34 +1521,18 @@ struct Scanner
|
||||||
{
|
{
|
||||||
// Scan the entire plain scalar.
|
// Scan the entire plain scalar.
|
||||||
size_t length;
|
size_t length;
|
||||||
dchar c = void;
|
dchar c = reader_.peek(length);
|
||||||
// Moved the if() out of the loop for optimization.
|
for(;;)
|
||||||
if(flowLevel_ == 0)
|
|
||||||
{
|
{
|
||||||
c = reader_.peek(length);
|
const cNext = reader_.peek(length + 1);
|
||||||
for(;;)
|
if(c.isWhiteSpace ||
|
||||||
|
(flowLevel_ == 0 && c == ':' && cNext.isWhiteSpace) ||
|
||||||
|
(flowLevel_ > 0 && c.among!(',', ':', '?', '[', ']', '{', '}')))
|
||||||
{
|
{
|
||||||
const cNext = reader_.peek(length + 1);
|
break;
|
||||||
if(c.isWhiteSpace ||
|
|
||||||
(c == ':' && cNext.isWhiteSpace))
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
++length;
|
|
||||||
c = cNext;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
c = reader_.peek(length);
|
|
||||||
if(c.isWhiteSpace || c.among!(',', ':', '?', '[', ']', '{', '}'))
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
++length;
|
|
||||||
}
|
}
|
||||||
|
++length;
|
||||||
|
c = cNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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