Skip to content

Commit b1ede37

Browse files
committed
rename: m10 -> mantissa
1 parent 3398cfe commit b1ede37

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

ext/json/ext/parser/parser.c

Lines changed: 12 additions & 12 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 m10, int m10digits, int32_t e10, bool signedM,
822+
static inline VALUE json_decode_float(JSON_ParserConfig *config, uint64_t mantissa, int mantissa_digits, int32_t e10, bool signedM,
823823
const char *start, const char *end)
824824
{
825825
if (RB_UNLIKELY(config->decimal_class)) {
@@ -829,11 +829,11 @@ static inline VALUE json_decode_float(JSON_ParserConfig *config, uint64_t m10, i
829829

830830
// Fall back to rb_cstr_to_dbl for potential subnormals (rare edge case)
831831
// Ryu has rounding issues with subnormals around 1e-310 (< 2.225e-308)
832-
if (RB_UNLIKELY(m10digits > 17 || m10digits + e10 < -307)) {
832+
if (RB_UNLIKELY(mantissa_digits > 17 || mantissa_digits + e10 < -307)) {
833833
return json_decode_large_float(start, end - start);
834834
}
835835

836-
double result = ryu_s2d_from_parts(m10, m10digits, e10, signedM);
836+
double result = ryu_s2d_from_parts(mantissa, mantissa_digits, e10, signedM);
837837
return DBL2NUM(result);
838838
}
839839

@@ -1095,8 +1095,8 @@ static VALUE json_parse_any(JSON_ParserState *state, JSON_ParserConfig *config)
10951095
bool integer = true;
10961096

10971097
// Variables for Ryu optimization - extract digits during parsing
1098-
uint64_t m10 = 0;
1099-
int m10digits = 0;
1098+
uint64_t mantissa = 0;
1099+
int mantissa_digits = 0;
11001100
int32_t e10 = 0;
11011101
bool signedM = false;
11021102
int decimal_point_pos = -1;
@@ -1115,8 +1115,8 @@ static VALUE json_parse_any(JSON_ParserState *state, JSON_ParserConfig *config)
11151115

11161116
// Parse integer part and extract mantissa digits
11171117
while ((state->cursor < state->end) && rb_isdigit(*state->cursor)) {
1118-
m10 = m10 * 10 + (*state->cursor - '0');
1119-
m10digits++;
1118+
mantissa = mantissa * 10 + (*state->cursor - '0');
1119+
mantissa_digits++;
11201120
state->cursor++;
11211121
}
11221122

@@ -1132,16 +1132,16 @@ static VALUE json_parse_any(JSON_ParserState *state, JSON_ParserConfig *config)
11321132
// Parse fractional part
11331133
if ((state->cursor < state->end) && (*state->cursor == '.')) {
11341134
integer = false;
1135-
decimal_point_pos = m10digits; // Remember position of decimal point
1135+
decimal_point_pos = mantissa_digits; // Remember position of decimal point
11361136
state->cursor++;
11371137

11381138
if (state->cursor == state->end || !rb_isdigit(*state->cursor)) {
11391139
raise_parse_error("invalid number: %s", state);
11401140
}
11411141

11421142
while ((state->cursor < state->end) && rb_isdigit(*state->cursor)) {
1143-
m10 = m10 * 10 + (*state->cursor - '0');
1144-
m10digits++;
1143+
mantissa = mantissa * 10 + (*state->cursor - '0');
1144+
mantissa_digits++;
11451145
state->cursor++;
11461146
}
11471147
}
@@ -1176,10 +1176,10 @@ static VALUE json_parse_any(JSON_ParserState *state, JSON_ParserConfig *config)
11761176

11771177
// Adjust exponent based on decimal point position
11781178
if (decimal_point_pos >= 0) {
1179-
e10 -= (m10digits - decimal_point_pos);
1179+
e10 -= (mantissa_digits - decimal_point_pos);
11801180
}
11811181

1182-
return json_push_value(state, config, json_decode_float(config, m10, m10digits, e10, signedM, start, state->cursor));
1182+
return json_push_value(state, config, json_decode_float(config, mantissa, mantissa_digits, e10, signedM, start, state->cursor));
11831183
}
11841184
case '"': {
11851185
// %r{\A"[^"\\\t\n\x00]*(?:\\[bfnrtu\\/"][^"\\]*)*"}

0 commit comments

Comments
 (0)