Skip to content

Commit 5ae2fba

Browse files
committed
cleanup for parse_number_string
1 parent 437a80c commit 5ae2fba

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

include/fast_float/ascii_number.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ template <typename UC> struct parsed_number_string_t {
268268
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
269269
bool negative{false};
270270
#endif
271-
bool valid{false};
271+
bool invalid{false};
272272
bool too_many_digits{false};
273273
// contains the range of the significant digits
274274
span<UC const> integer{}; // non-nullable
@@ -283,7 +283,7 @@ template <typename UC>
283283
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 parsed_number_string_t<UC>
284284
report_parse_error(UC const *p, parse_error error) noexcept {
285285
parsed_number_string_t<UC> answer;
286-
answer.valid = false;
286+
answer.invalid = true;
287287
answer.lastmatch = p;
288288
answer.error = error;
289289
return answer;
@@ -299,7 +299,8 @@ parse_number_string(UC const *p, UC const *pend,
299299
// Consider refactoring the 'parse_number_string' function.
300300
// FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN fix this.
301301
parsed_number_string_t<UC> answer;
302-
FASTFLOAT_ASSUME(p < pend); // so dereference without checks;
302+
// so dereference without checks
303+
FASTFLOAT_ASSUME(p < pend);
303304
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
304305
answer.negative = (*p == UC('-'));
305306
if (answer.negative ||
@@ -312,15 +313,15 @@ parse_number_string(UC const *p, UC const *pend,
312313
p, parse_error::missing_integer_or_dot_after_sign);
313314
}
314315
FASTFLOAT_IF_CONSTEXPR17(basic_json_fmt) {
315-
if (!is_integer(*p)) { // a sign must be followed by an integer
316+
// a sign must be followed by an integer
317+
if (!is_integer(*p)) {
316318
return report_parse_error<UC>(p,
317319
parse_error::missing_integer_after_sign);
318320
}
319321
}
320322
else {
321-
if (!is_integer(*p) &&
322-
(*p != options.decimal_point)) { // a sign must be followed by an
323-
// integer or the dot
323+
// a sign must be followed by an integer or the dot
324+
if (!is_integer(*p) && (*p != options.decimal_point)) {
324325
return report_parse_error<UC>(
325326
p, parse_error::missing_integer_or_dot_after_sign);
326327
}
@@ -459,7 +460,6 @@ parse_number_string(UC const *p, UC const *pend,
459460

460461
// We parsed all parts of the number, let's save progress.
461462
answer.lastmatch = p;
462-
answer.valid = true;
463463

464464
// Now we can check for errors.
465465

include/fast_float/parse_number.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ from_chars_float_advanced(UC const *first, UC const *last, T &value,
337337
:
338338
#endif
339339
parse_number_string<false, UC>(first, last, options);
340-
if (!pns.valid) {
340+
if (pns.invalid) {
341341
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
342342
if (chars_format_t(options.format & chars_format::no_infnan)) {
343343
#endif

0 commit comments

Comments
 (0)