Address review comments on operator[](json_pointer) rollback
- undo() shrinks the array with resize() instead of erase() - comments say what "will be" done in get_unchecked_create - tests: avoid a clang-tidy performance-unnecessary-copy-initialization hit (unit-alt-string) and the word "access" in section names, which Flawfinder flags as race/access Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
4 files changed
+13
-13
No files matched your search
Generated
+4
-4
@@ -24875,7 +24875,7 @@ class json_pointer
|
||||
case change::array_grown:
|
||||
{
|
||||
auto& elements = *m_value->m_data.m_value.array;
|
||||
elements.erase(std::next(elements.begin(), static_cast<typename BasicJsonType::difference_type>(m_old_size)), elements.end());
|
||||
elements.resize(m_old_size);
|
||||
break;
|
||||
}
|
||||
case change::none:
|
||||
@@ -25336,7 +25336,7 @@ class json_pointer
|
||||
// explicitly treat "-" as index beyond the end
|
||||
return array_append(*ptr);
|
||||
}
|
||||
// an element is appended in get_unchecked_create
|
||||
// an element will be appended in get_unchecked_create
|
||||
break;
|
||||
}
|
||||
if (token + 1 == end)
|
||||
@@ -25347,14 +25347,14 @@ class json_pointer
|
||||
const auto idx = array_index<BasicJsonType>(*token);
|
||||
if (idx >= ptr->m_data.m_value.array->size())
|
||||
{
|
||||
// the array is padded in get_unchecked_create
|
||||
// the array will be padded in get_unchecked_create
|
||||
break;
|
||||
}
|
||||
ptr = &(*ptr->m_data.m_value.array)[idx];
|
||||
}
|
||||
else if (ptr->is_null())
|
||||
{
|
||||
// the null value is converted in get_unchecked_create
|
||||
// the null value will be converted in get_unchecked_create
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in new issue
Block a user