Browse Source

Merge pull request #24 from masamitsu-murase/use_compare

Use string::compare to improve performance.
master
j4cbo 8 years ago
parent
commit
be631169db
  1. 5
      json11.cpp

5
json11.cpp

@ -547,12 +547,11 @@ struct JsonParser {
Json expect(const string &expected, Json res) {
assert(i != 0);
i--;
const string found = str.substr(i, expected.length());
if (expected == found) {
if (str.compare(i, expected.length(), expected) == 0) {
i += expected.length();
return res;
} else {
return fail("parse error: expected " + expected + ", got " + found);
return fail("parse error: expected " + expected + ", got " + str.substr(i, expected.length()));
}
}

Loading…
Cancel
Save