Test more strides

This commit is contained in:
2025-05-21 16:19:58 -04:00
parent 611d1a07de
commit 0b68fd1d41
2 changed files with 14 additions and 6 deletions

View File

@@ -192,7 +192,7 @@ inline std::string toString(JsonValue const &jsonValue) {
__builtin_unreachable();
}
inline std::optional<JsonValue> toValue(std::string copy, int stride = 0) {
inline std::optional<JsonValue> toValue(std::string copy, int stride) {
ReadValueState state;
auto c = readValueCallbacks();
parser3::Parser3 parser(&c, &state);
@@ -202,7 +202,8 @@ inline std::optional<JsonValue> toValue(std::string copy, int stride = 0) {
}
} else {
for (int i = 0; i < copy.size(); i += stride) {
if (parser.parse(copy.data(), std::min<int>(stride, copy.size() - i)) !=
if (parser.parse(copy.data() + i,
std::min<int>(stride, copy.size() - i)) !=
parser3::S_AGAIN) {
return std::nullopt;
}