mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
fix(minifier): use to_js_string() instead of fs64::to_string (#6597)
This commit is contained in:
parent
071e5643f3
commit
16bea12f9c
1 changed files with 8 additions and 8 deletions
|
|
@ -12,7 +12,7 @@ use oxc_ecmascript::{
|
||||||
};
|
};
|
||||||
use oxc_span::{GetSpan, Span, SPAN};
|
use oxc_span::{GetSpan, Span, SPAN};
|
||||||
use oxc_syntax::{
|
use oxc_syntax::{
|
||||||
number::NumberBase,
|
number::{NumberBase, ToJsString},
|
||||||
operator::{BinaryOperator, LogicalOperator, UnaryOperator},
|
operator::{BinaryOperator, LogicalOperator, UnaryOperator},
|
||||||
};
|
};
|
||||||
use oxc_traverse::{Ancestor, Traverse, TraverseCtx};
|
use oxc_traverse::{Ancestor, Traverse, TraverseCtx};
|
||||||
|
|
@ -487,9 +487,9 @@ impl<'a, 'b> PeepholeFoldConstants {
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let result_str = result.to_string().len();
|
let result_str = result.to_js_string().len();
|
||||||
let original_str =
|
let original_str =
|
||||||
left.to_string().len() + right.to_string().len() + length_of_operator;
|
left.to_js_string().len() + right.to_js_string().len() + length_of_operator;
|
||||||
result_str <= original_str
|
result_str <= original_str
|
||||||
}
|
}
|
||||||
if !operation.operator.is_arithmetic() {
|
if !operation.operator.is_arithmetic() {
|
||||||
|
|
@ -538,7 +538,7 @@ impl<'a, 'b> PeepholeFoldConstants {
|
||||||
Some(ctx.ast.expression_numeric_literal(
|
Some(ctx.ast.expression_numeric_literal(
|
||||||
operation.span,
|
operation.span,
|
||||||
result,
|
result,
|
||||||
result.to_string(),
|
result.to_js_string(),
|
||||||
number_base,
|
number_base,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
@ -582,7 +582,7 @@ impl<'a, 'b> PeepholeFoldConstants {
|
||||||
_ => ctx.ast.expression_numeric_literal(
|
_ => ctx.ast.expression_numeric_literal(
|
||||||
SPAN,
|
SPAN,
|
||||||
result,
|
result,
|
||||||
result.to_string(),
|
result.to_js_string(),
|
||||||
if is_exact_int64(result) { NumberBase::Decimal } else { NumberBase::Float },
|
if is_exact_int64(result) { NumberBase::Decimal } else { NumberBase::Float },
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
@ -676,7 +676,7 @@ impl<'a, 'b> PeepholeFoldConstants {
|
||||||
let number_literal_expr = ctx.ast.expression_numeric_literal(
|
let number_literal_expr = ctx.ast.expression_numeric_literal(
|
||||||
right_expr.span(),
|
right_expr.span(),
|
||||||
num,
|
num,
|
||||||
num.to_string(),
|
num.to_js_string(),
|
||||||
if num.fract() == 0.0 { NumberBase::Decimal } else { NumberBase::Float },
|
if num.fract() == 0.0 { NumberBase::Decimal } else { NumberBase::Float },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -699,7 +699,7 @@ impl<'a, 'b> PeepholeFoldConstants {
|
||||||
let number_literal_expr = ctx.ast.expression_numeric_literal(
|
let number_literal_expr = ctx.ast.expression_numeric_literal(
|
||||||
left_expr.span(),
|
left_expr.span(),
|
||||||
num,
|
num,
|
||||||
num.to_string(),
|
num.to_js_string(),
|
||||||
if num.fract() == 0.0 { NumberBase::Decimal } else { NumberBase::Float },
|
if num.fract() == 0.0 { NumberBase::Decimal } else { NumberBase::Float },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -967,7 +967,7 @@ impl<'a, 'b> PeepholeFoldConstants {
|
||||||
return Some(ctx.ast.expression_numeric_literal(
|
return Some(ctx.ast.expression_numeric_literal(
|
||||||
span,
|
span,
|
||||||
result_val,
|
result_val,
|
||||||
result_val.to_string(),
|
result_val.to_js_string(),
|
||||||
NumberBase::Decimal,
|
NumberBase::Decimal,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue