Combine prime and parse

This commit is contained in:
2025-05-17 13:41:28 -04:00
parent e10fb92801
commit 37c860ce62
2 changed files with 9 additions and 14 deletions

View File

@@ -542,18 +542,15 @@ TEST_CASE("parser2") {
Parser2 parser(&c, &state);
int i = 0;
for (; i < copy.length() - 1; ++i) {
parser.prime(copy.data() + i, 1);
REQUIRE(parser.parse() == Parser2::S_AGAIN);
REQUIRE(parser.parse(copy.data() + i, 1) == Parser2::S_AGAIN);
}
parser.prime(copy.data() + i, 1);
CHECK(parser.parse() == Parser2::S_OK);
CHECK(parser.parse(copy.data() + i, 1) == Parser2::S_OK);
puts("");
}
{
std::string copy = "{\"x\": [], \"y\": {}}";
Parser2 parser(&c, &state);
parser.prime(copy.data(), copy.length());
CHECK(parser.parse() == Parser2::S_OK);
CHECK(parser.parse(copy.data(), copy.length()) == Parser2::S_OK);
puts("");
}
}
@@ -578,8 +575,7 @@ TEST_CASE("bench2") {
bench.run("parser2", [&]() {
auto copy = json;
Parser2 parser(&c, nullptr);
parser.prime(copy.data(), copy.length());
bench.doNotOptimizeAway(parser.parse());
bench.doNotOptimizeAway(parser.parse(copy.data(), copy.length()));
});
}