mirror of
https://github.com/nlohmann/json.git
synced 2026-09-06 16:27:59 +00:00
Share the position-counter bump between get() and get_ignoring_pending_unget()
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
@@ -1446,8 +1446,7 @@ scan_number_done:
|
||||
*/
|
||||
char_int_type get()
|
||||
{
|
||||
++position.chars_read_total;
|
||||
++position.chars_read_current_line;
|
||||
advance_position();
|
||||
|
||||
if (next_unget)
|
||||
{
|
||||
@@ -1462,6 +1461,15 @@ scan_number_done:
|
||||
return track_after_read();
|
||||
}
|
||||
|
||||
/// shared head of get() / get_ignoring_pending_unget(): bump the
|
||||
/// per-character position counters (line-count-on-'\n' bookkeeping is
|
||||
/// handled afterwards, in track_after_read(), once `current` is known)
|
||||
void advance_position() noexcept
|
||||
{
|
||||
++position.chars_read_total;
|
||||
++position.chars_read_current_line;
|
||||
}
|
||||
|
||||
/// shared tail of get() / get_ignoring_pending_unget(): capture the
|
||||
/// character for error messages (if needed) and update line/column
|
||||
/// bookkeeping for the character now in `current`
|
||||
@@ -1497,8 +1505,7 @@ scan_number_done:
|
||||
{
|
||||
JSON_ASSERT(!next_unget);
|
||||
|
||||
++position.chars_read_total;
|
||||
++position.chars_read_current_line;
|
||||
advance_position();
|
||||
current = ia.get_character();
|
||||
|
||||
return track_after_read();
|
||||
|
||||
Reference in New Issue
Block a user