mirror of
https://github.com/nlohmann/json.git
synced 2026-10-22 14:08:13 +00:00
A patch from diff() lists its operations in document order, so consecutive pointers share most of their reference tokens. resolve_plain() now keeps the values along the pointer it resolved last and resumes from the deepest one that is also a prefix of the next pointer, instead of walking every pointer from the root. The values stay valid because a plain operation only changes the target (replace) or its parent (add, remove), and the general operations reset the cache. The "~" check covers only the part of the pointer that is resolved anew. The members "op", "path", "value", and "from" of an operation are found in one pass over its object instead of up to four lookups (for key types other than string_t, by lookup). patch() on the diff of every eighth scalar (instructions on macOS, Linux Ir GCC 13 / Clang 18): canada 85.8M -> 67.7M, 67.4M -> 42.6M / 70.0M -> 43.6M; citm_catalog 28.7M -> 27.1M, 20.7M -> 18.1M / 20.7M -> 18.0M; twitter 14.3M -> 13.2M, 11.4M -> 9.5M / 11.3M -> 9.4M. Exceptions and results are unchanged. Signed-off-by: Niels Lohmann <mail@nlohmann.me>