mirror of
https://github.com/nlohmann/json.git
synced 2026-09-06 08:17: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()
|
char_int_type get()
|
||||||
{
|
{
|
||||||
++position.chars_read_total;
|
advance_position();
|
||||||
++position.chars_read_current_line;
|
|
||||||
|
|
||||||
if (next_unget)
|
if (next_unget)
|
||||||
{
|
{
|
||||||
@@ -1462,6 +1461,15 @@ scan_number_done:
|
|||||||
return track_after_read();
|
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
|
/// shared tail of get() / get_ignoring_pending_unget(): capture the
|
||||||
/// character for error messages (if needed) and update line/column
|
/// character for error messages (if needed) and update line/column
|
||||||
/// bookkeeping for the character now in `current`
|
/// bookkeeping for the character now in `current`
|
||||||
@@ -1497,8 +1505,7 @@ scan_number_done:
|
|||||||
{
|
{
|
||||||
JSON_ASSERT(!next_unget);
|
JSON_ASSERT(!next_unget);
|
||||||
|
|
||||||
++position.chars_read_total;
|
advance_position();
|
||||||
++position.chars_read_current_line;
|
|
||||||
current = ia.get_character();
|
current = ia.get_character();
|
||||||
|
|
||||||
return track_after_read();
|
return track_after_read();
|
||||||
|
|||||||
@@ -9229,8 +9229,7 @@ scan_number_done:
|
|||||||
*/
|
*/
|
||||||
char_int_type get()
|
char_int_type get()
|
||||||
{
|
{
|
||||||
++position.chars_read_total;
|
advance_position();
|
||||||
++position.chars_read_current_line;
|
|
||||||
|
|
||||||
if (next_unget)
|
if (next_unget)
|
||||||
{
|
{
|
||||||
@@ -9245,6 +9244,15 @@ scan_number_done:
|
|||||||
return track_after_read();
|
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
|
/// shared tail of get() / get_ignoring_pending_unget(): capture the
|
||||||
/// character for error messages (if needed) and update line/column
|
/// character for error messages (if needed) and update line/column
|
||||||
/// bookkeeping for the character now in `current`
|
/// bookkeeping for the character now in `current`
|
||||||
@@ -9280,8 +9288,7 @@ scan_number_done:
|
|||||||
{
|
{
|
||||||
JSON_ASSERT(!next_unget);
|
JSON_ASSERT(!next_unget);
|
||||||
|
|
||||||
++position.chars_read_total;
|
advance_position();
|
||||||
++position.chars_read_current_line;
|
|
||||||
current = ia.get_character();
|
current = ia.get_character();
|
||||||
|
|
||||||
return track_after_read();
|
return track_after_read();
|
||||||
|
|||||||
Reference in New Issue
Block a user