1
1
use std:: borrow:: Cow ;
2
2
3
+ use cow_utils:: CowUtils ;
3
4
use oxc_ast:: { ast:: NumericLiteral , AstKind } ;
4
5
use oxc_diagnostics:: OxcDiagnostic ;
5
6
use oxc_macros:: declare_oxc_lint;
@@ -182,16 +183,9 @@ impl<'a> RawNum<'a> {
182
183
}
183
184
184
185
impl NoLossOfPrecision {
185
- fn get_raw < ' a > ( node : & ' a NumericLiteral ) -> Cow < ' a , str > {
186
- if node. raw . contains ( '_' ) {
187
- Cow :: Owned ( node. raw . replace ( '_' , "" ) )
188
- } else {
189
- Cow :: Borrowed ( node. raw )
190
- }
191
- }
192
-
193
186
fn not_base_ten_loses_precision ( node : & ' _ NumericLiteral ) -> bool {
194
- let raw = Self :: get_raw ( node) . to_uppercase ( ) ;
187
+ let raw = node. raw . cow_replace ( '_' , "" ) ;
188
+ let raw = raw. cow_to_uppercase ( ) ;
195
189
#[ allow( clippy:: cast_possible_truncation, clippy:: cast_sign_loss) ]
196
190
// AST always store number as f64, need a cast to format in bin/oct/hex
197
191
let value = node. value as u64 ;
@@ -206,7 +200,7 @@ impl NoLossOfPrecision {
206
200
}
207
201
208
202
fn base_ten_loses_precision ( node : & ' _ NumericLiteral ) -> bool {
209
- let raw = Self :: get_raw ( node) ;
203
+ let raw = node. raw . cow_replace ( '_' , "" ) ;
210
204
let Some ( raw) = Self :: normalize ( & raw ) else {
211
205
return true ;
212
206
} ;
0 commit comments