Skip to content

Commit 6d42d3f

Browse files
committed
Rename signedM -> nagative
1 parent 60ecafe commit 6d42d3f

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

ext/json/ext/parser/parser.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ static VALUE json_decode_large_float(const char *start, long len)
819819
/* Ruby JSON optimized float decoder using vendored Ryu algorithm
820820
* Accepts pre-extracted mantissa and exponent from first-pass validation
821821
*/
822-
static inline VALUE json_decode_float(JSON_ParserConfig *config, uint64_t mantissa, int mantissa_digits, int32_t exponent, bool signedM,
822+
static inline VALUE json_decode_float(JSON_ParserConfig *config, uint64_t mantissa, int mantissa_digits, int32_t exponent, bool negative,
823823
const char *start, const char *end)
824824
{
825825
if (RB_UNLIKELY(config->decimal_class)) {
@@ -833,8 +833,7 @@ static inline VALUE json_decode_float(JSON_ParserConfig *config, uint64_t mantis
833833
return json_decode_large_float(start, end - start);
834834
}
835835

836-
double result = ryu_s2d_from_parts(mantissa, mantissa_digits, exponent, signedM);
837-
return DBL2NUM(result);
836+
return DBL2NUM(ryu_s2d_from_parts(mantissa, mantissa_digits, exponent, negative));
838837
}
839838

840839
static inline VALUE json_decode_array(JSON_ParserState *state, JSON_ParserConfig *config, long count)
@@ -1098,15 +1097,15 @@ static VALUE json_parse_any(JSON_ParserState *state, JSON_ParserConfig *config)
10981097
uint64_t mantissa = 0;
10991098
int mantissa_digits = 0;
11001099
int32_t exponent = 0;
1101-
bool signedM = false;
1100+
bool negative = false;
11021101
int decimal_point_pos = -1;
11031102

11041103
// /\A-?(0|[1-9]\d*)(\.\d+)?([Ee][-+]?\d+)?/
11051104
const char *start = state->cursor;
11061105

11071106
// Handle optional negative sign
11081107
if (*state->cursor == '-') {
1109-
signedM = true;
1108+
negative = true;
11101109
state->cursor++;
11111110
if (state->cursor >= state->end || !rb_isdigit(*state->cursor)) {
11121111
raise_parse_error_at("invalid number: %s", state, start);
@@ -1121,11 +1120,11 @@ static VALUE json_parse_any(JSON_ParserState *state, JSON_ParserConfig *config)
11211120
}
11221121

11231122
long integer_length = state->cursor - start;
1124-
if (signedM) integer_length--; // Don't count the sign
1123+
if (negative) integer_length--; // Don't count the sign
11251124

11261125
if (RB_UNLIKELY(start[0] == '0' && integer_length > 1)) {
11271126
raise_parse_error_at("invalid number: %s", state, start);
1128-
} else if (RB_UNLIKELY(integer_length > 1 && signedM && start[1] == '0')) {
1127+
} else if (RB_UNLIKELY(integer_length > 1 && negative && start[1] == '0')) {
11291128
raise_parse_error_at("invalid number: %s", state, start);
11301129
}
11311130

@@ -1180,7 +1179,7 @@ static VALUE json_parse_any(JSON_ParserState *state, JSON_ParserConfig *config)
11801179
exponent -= (mantissa_digits - decimal_point_pos);
11811180
}
11821181

1183-
return json_push_value(state, config, json_decode_float(config, mantissa, mantissa_digits, exponent, signedM, start, state->cursor));
1182+
return json_push_value(state, config, json_decode_float(config, mantissa, mantissa_digits, exponent, negative, start, state->cursor));
11841183
}
11851184
case '"': {
11861185
// %r{\A"[^"\\\t\n\x00]*(?:\\[bfnrtu\\/"][^"\\]*)*"}

0 commit comments

Comments
 (0)