Merge pull request #252 from Herringway/undo-false-optimizations
undo some false optimizations merged-on-behalf-of: Cameron Ross <elpenguino@gmail.com>
This commit is contained in:
commit
0b92d5a2f9
|
@ -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,35 +1521,19 @@ 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.
|
|
||||||
if(flowLevel_ == 0)
|
|
||||||
{
|
|
||||||
c = reader_.peek(length);
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
const cNext = reader_.peek(length + 1);
|
const cNext = reader_.peek(length + 1);
|
||||||
if(c.isWhiteSpace ||
|
if(c.isWhiteSpace ||
|
||||||
(c == ':' && cNext.isWhiteSpace))
|
(flowLevel_ == 0 && c == ':' && cNext.isWhiteSpace) ||
|
||||||
|
(flowLevel_ > 0 && c.among!(',', ':', '?', '[', ']', '{', '}')))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++length;
|
++length;
|
||||||
c = cNext;
|
c = cNext;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
c = reader_.peek(length);
|
|
||||||
if(c.isWhiteSpace || c.among!(',', ':', '?', '[', ']', '{', '}'))
|
|
||||||
{
|
|
||||||
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.
|
||||||
enforce(flowLevel_ == 0 || c != ':' ||
|
enforce(flowLevel_ == 0 || c != ':' ||
|
||||||
|
|
Loading…
Reference in a new issue