mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 12:41:17 +00:00
Avoid copying cached RegExes for scalars
This improves performance on the test.yaml attached to #158 by about 25% on my machine as compared to the previous commit (0.25s -> 0.20s), as measured by `time build/util/parse < test.yaml > /dev/null`.
This commit is contained in:

committed by
Jesse Beder

parent
8c35a8ffab
commit
005a6a19ee
@@ -28,13 +28,17 @@ std::string ScanScalar(Stream& INPUT, ScanScalarParams& params) {
|
||||
std::string scalar;
|
||||
params.leadingSpaces = false;
|
||||
|
||||
if (!params.end) {
|
||||
params.end = &Exp::Empty();
|
||||
}
|
||||
|
||||
while (INPUT) {
|
||||
// ********************************
|
||||
// Phase #1: scan until line ending
|
||||
|
||||
std::size_t lastNonWhitespaceChar = scalar.size();
|
||||
bool escapedNewline = false;
|
||||
while (!params.end.Matches(INPUT) && !Exp::Break().Matches(INPUT)) {
|
||||
while (!params.end->Matches(INPUT) && !Exp::Break().Matches(INPUT)) {
|
||||
if (!INPUT)
|
||||
break;
|
||||
|
||||
@@ -87,7 +91,7 @@ std::string ScanScalar(Stream& INPUT, ScanScalarParams& params) {
|
||||
break;
|
||||
|
||||
// are we done via character match?
|
||||
int n = params.end.Match(INPUT);
|
||||
int n = params.end->Match(INPUT);
|
||||
if (n >= 0) {
|
||||
if (params.eatEnd)
|
||||
INPUT.eat(n);
|
||||
|
Reference in New Issue
Block a user