json_view: remove checks that invariants make dead
Branch coverage of the test suite and of 24k mutated inputs showed these conditions as never taken; each is implied by the code around it: - view_serializer::write_codepoint<EnsureAscii>(): the only caller passes the byte a run of plain output stopped at (a quote, a backslash or a control character), so the function is now write_escaped(), which writes that byte's escape sequence - load_image(): `owned_image.empty() || image != owned_image.data()`; both callers hand in a fresh document_data, and for load(vector&&) the image is owned_image itself - set_moved(): reserve_moved(); all three callers reserved first or have the moved flag set (the documented precondition) - view_side::string() and json_side::string() in equal(): only used after both sides were found to be strings, so they read the string directly (and are noexcept) - number<false>(): the '1'..'9' test after a sign-less dispatch, which only happens for a digit - value_range(): the pre-loop `is_new || off >= size` test, which the loop's first pass repeats on the same node No change in behaviour: a build that aborts on each removed side passes the test suite and the fuzz corpora. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
7 files changed
+24
-46
No files matched your search
@@ -787,10 +787,6 @@ inline void load_image(document_data& d, const std::uint8_t* image, std::size_t
|
||||
d.edits.reset();
|
||||
d.base[2] = nullptr;
|
||||
d.owned.clear();
|
||||
if (d.owned_image.empty() || image != d.owned_image.data())
|
||||
{
|
||||
d.owned_image.clear();
|
||||
}
|
||||
d.arena.clear();
|
||||
d.indexes.clear();
|
||||
d.index_slots.clear();
|
||||
|
||||
Reference in new issue
Block a user