1- use std:: borrow:: Cow ;
2-
31use boa_gc:: { Finalize , Trace } ;
42use fixed_decimal:: { Decimal , FloatPrecision , SignDisplay } ;
53use icu_decimal:: {
@@ -30,7 +28,7 @@ use crate::{
3028 NativeFunction ,
3129 builtins:: {
3230 BuiltInConstructor , BuiltInObject , IntrinsicObject , builder:: BuiltInBuilder ,
33- options:: get_option, string :: is_trimmable_whitespace ,
31+ options:: get_option,
3432 } ,
3533 context:: intrinsics:: { Intrinsics , StandardConstructor , StandardConstructors } ,
3634 js_string,
@@ -825,13 +823,12 @@ fn to_intl_mathematical_value(value: &JsValue, context: &mut Context) -> JsResul
825823pub ( crate ) fn js_string_to_fixed_decimal ( string : & JsString ) -> Option < Decimal > {
826824 // 1. Let text be ! StringToCodePoints(str).
827825 // 2. Let literal be ParseText(text, StringNumericLiteral).
828- let Ok ( string) = string. to_std_string ( ) else {
826+ let Ok ( string) = string. trim ( ) . to_std_string ( ) else {
829827 // 3. If literal is a List of errors, return NaN.
830828 return None ;
831829 } ;
832830 // 4. Return StringNumericValue of literal.
833- let string = string. trim_matches ( is_trimmable_whitespace) ;
834- match string {
831+ match string. as_str ( ) {
835832 "" => return Some ( Decimal :: from ( 0 ) ) ,
836833 "-Infinity" | "Infinity" | "+Infinity" => return None ,
837834 _ => { }
@@ -856,11 +853,10 @@ pub(crate) fn js_string_to_fixed_decimal(string: &JsString) -> Option<Decimal> {
856853 return None ;
857854 }
858855 let int = BigInt :: from_str_radix ( string, base) . ok ( ) ?;
859- let int_str = int. to_string ( ) ;
860856
861- Cow :: Owned ( int_str )
857+ int . to_string ( )
862858 } else {
863- Cow :: Borrowed ( string)
859+ string
864860 } ;
865861
866862 Decimal :: try_from_str ( & s) . ok ( )
0 commit comments