Contiguous parser: review fixes (wording, macros, diagnostic positions)

- "default parser" instead of "library parser" in comments and tests
- the three comments in json.hpp say the same thing
- current() replaces the repeated `p != end ? *p : 0`
- the backslashes of each macro are aligned
- the docs say that JSON_DIAGNOSTIC_POSITIONS turns the fast path off

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann committed 2026-11-07 10:16:20 +01:00
1 parent 7960f33af8
commit 181f41487f
6 files changed
+294 -274

No files matched your search

+6 -5
View File
@@ -3111,7 +3111,7 @@ public:
{
basic_json result;
// JSON in one block of memory, with the default options, is read by
// the faster contiguous_parser; on an error, the library parser reads
// the faster contiguous_parser; on an error, the default parser reads
// it again to report it (see contiguous_parser)
using contiguous = std::integral_constant<bool, detail::can_parse_contiguous<basic_json, typename std::decay<InputAdapterType>::type>::value>;
if (cb == nullptr && !ignore_comments && !ignore_trailing_commas
@@ -3129,8 +3129,8 @@ public:
const bool ignore_comments,
const bool ignore_trailing_commas)
{
// JSON in one block of memory is checked by the faster
// contiguous_parser (see parse_impl())
// JSON in one block of memory, with the default options, is checked by
// the faster contiguous_parser (see parse_impl())
using adapter_t = typename std::decay<InputAdapterType>::type;
bool accepted = false;
if (!ignore_comments && !ignore_trailing_commas
@@ -3154,8 +3154,9 @@ public:
{
if (format == input_format_t::json)
{
// JSON in one block of memory is read by the faster
// contiguous_parser, with the default options (see parse_impl())
// JSON in one block of memory, with the default options, is read by
// the faster contiguous_parser; on an error, the default parser
// reads it again to report it (see parse_impl())
bool result = false;
if (strict && !ignore_comments && !ignore_trailing_commas
&& detail::sax_parse_contiguous<basic_json>(ia, sax, result, std::integral_constant<bool, detail::can_parse_contiguous<basic_json, InputAdapterType>::value> {}))