json_view: keep GCC from cloning scan_string_vector

With the builder of accept() in the same translation unit, GCC 16's
interprocedural constant propagation cloned scan_string_vector without its
plain argument (always string_plain()). The parse loop of
json_document::parse() then called the clone, and GCC generated different
code for the whole loop: 0.7-1.2 % more instructions (twitter, citm_catalog,
instruments, tree-pretty, canada) and up to +13 % time on citm_catalog.
NLOHMANN_VIEW_NOCLONE (GCC only) keeps the function as written; the
instruction counts of parse() are then those of develop again.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann committed 2026-10-31 18:03:40 +01:00
1 parent 56c6eaf2ad
commit 6548a65b46
5 files changed
+31 -5

No files matched your search

@@ -15,6 +15,7 @@
#undef NLOHMANN_VIEW_UNLIKELY
#undef NLOHMANN_VIEW_ALWAYS_INLINE
#undef NLOHMANN_VIEW_NOINLINE
#undef NLOHMANN_VIEW_NOCLONE
#undef NLOHMANN_VIEW_NODISCARD
#undef NLOHMANN_VIEW_THROW
#undef NLOHMANN_VIEW_LITTLE_ENDIAN