mirror of
https://github.com/nlohmann/json.git
synced 2026-08-29 04:17:32 +00:00
Do not repeat the integer conversion that just failed
scan_number_bulk_contiguous() converts an integer token straight from the input buffer. When the value does not fit, it materializes token_buffer and calls convert_number(), which tried the very same integer conversion again before falling back to floating point. Recording the outcome in number_type skips the second attempt. The resulting token type and value are unchanged: convert_number() reached the float tail either way. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MXDi7NTMKAmoArUZSKMc4T Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
@@ -1538,7 +1538,10 @@ scan_number_done:
|
||||
position.chars_read_current_line += (len - 1);
|
||||
return integer_result;
|
||||
}
|
||||
// the value overflowed: fall through and let the float tail handle it
|
||||
// The value does not fit an integer, so this token converts as a
|
||||
// float. Recording that here keeps convert_number() below from
|
||||
// repeating the integer attempt that just failed.
|
||||
number_type = token_type::value_float;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user