Skip to content

Commit 0520894

Browse files
committed
remove fast-float crate as std float parse is now also using Eisel-Lemire algorithm
rust-lang/rust#86761
1 parent 723443e commit 0520894

File tree

9 files changed

+15
-19
lines changed

9 files changed

+15
-19
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ eudex = { version = "0.1", optional = true }
9797
ext-sort = { version = "0.1", features = [
9898
"memory-limit",
9999
], default-features = false }
100-
fast-float = "0.2"
101100
fastrand = "2"
102101
flate2 = { version = "1", optional = true }
103102
file-format = { version = "0.22", features = ["reader"] }

src/cmd/apply.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,7 @@ fn apply_operations(
11061106
*cell = censor.count(cell).to_string();
11071107
},
11081108
Operations::Thousands => {
1109-
if let Ok(num) = fast_float::parse::<f64, _>(&cell) {
1109+
if let Ok(num) = cell.parse::<f64>() {
11101110
let mut temp_string = num.separate_by_policy(*THOUSANDS_POLICY.get().unwrap());
11111111

11121112
// if there is a decimal separator (fractional part > 0.0), use the requested
@@ -1131,7 +1131,7 @@ fn apply_operations(
11311131
}
11321132
},
11331133
Operations::Round => {
1134-
if let Ok(num) = fast_float::parse::<f64, _>(&cell) {
1134+
if let Ok(num) = cell.parse::<f64>() {
11351135
*cell = util::round_num(num, *ROUND_PLACES.get().unwrap());
11361136
}
11371137
},
@@ -1172,10 +1172,8 @@ fn apply_operations(
11721172
};
11731173

11741174
if let Ok(currency_value) = Currency::from_str(&cell_val) {
1175-
let currency_wrk = currency_value.convert(
1176-
fast_float::parse::<f64, _>(replacement).unwrap_or(1.0_f64),
1177-
comparand,
1178-
);
1175+
let currency_wrk = currency_value
1176+
.convert(replacement.parse::<f64>().unwrap_or(1.0_f64), comparand);
11791177
*cell = if formatstr.contains("euro") {
11801178
format!("{currency_wrk:e}")
11811179
} else {

src/cmd/applydp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ fn applydp_operations(
725725
*cell = regexreplace.replace_all(cell, replacement).to_string();
726726
},
727727
Operations::Round => {
728-
if let Ok(num) = fast_float::parse(&cell) {
728+
if let Ok(num) = cell.parse::<f64>() {
729729
*cell = util::round_num(num, *ROUND_PLACES.get().unwrap());
730730
}
731731
},

src/cmd/geocode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,8 +1529,8 @@ fn search_index(
15291529

15301530
let loccaps = locregex.captures(cell);
15311531
if let Some(loccaps) = loccaps {
1532-
let lat = fast_float::parse(&loccaps[1]).unwrap_or_default();
1533-
let long = fast_float::parse(&loccaps[2]).unwrap_or_default();
1532+
let lat = loccaps[1].to_string().parse::<f32>().unwrap_or_default();
1533+
let long = loccaps[2].to_string().parse::<f32>().unwrap_or_default();
15341534
if (-90.0..=90.0).contains(&lat) && (-180.0..=180.0).contains(&long) {
15351535
let search_result = engine.reverse((lat, long), 1, k, country_filter_list.as_deref());
15361536
let Some(cityrecord) = (match search_result {

src/cmd/schema.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,15 +353,15 @@ pub fn infer_schema_from_stats(args: &Args, input_filename: &str) -> CliResult<M
353353
type_list.push(Value::String("number".to_string()));
354354

355355
if let Some(min_str) = stats_record.get(stats_col_index_map["min"]) {
356-
let min = fast_float::parse::<f64, _>(min_str).unwrap();
356+
let min = min_str.parse::<f64>().unwrap();
357357
field_map.insert(
358358
"minimum".to_string(),
359359
Value::Number(Number::from_f64(min).unwrap()),
360360
);
361361
};
362362

363363
if let Some(max_str) = stats_record.get(stats_col_index_map["max"]) {
364-
let max = fast_float::parse::<f64, _>(max_str).unwrap();
364+
let max = max_str.parse::<f64>().unwrap();
365365
field_map.insert(
366366
"maximum".to_string(),
367367
Value::Number(Number::from_f64(max).unwrap()),

src/cmd/sort.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ where
313313
.and_then(|s| {
314314
if let Ok(i) = s.parse::<i64>() {
315315
Some(Number::Int(i))
316-
} else if let Ok(f) = fast_float::parse(s) {
316+
} else if let Ok(f) = s.parse::<f64>() {
317317
Some(Number::Float(f))
318318
} else {
319319
None

src/cmd/stats.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,7 @@ impl Stats {
12361236
// sum
12371237
if let Some(sum) = self.sum.as_ref().and_then(|sum| sum.show(typ)) {
12381238
if typ == FieldType::TFloat {
1239-
if let Ok(f64_val) = fast_float::parse::<f64, _>(&sum) {
1239+
if let Ok(f64_val) = sum.parse::<f64>() {
12401240
pieces.push(util::round_num(f64_val, round_places));
12411241
} else {
12421242
pieces.push(format!("ERROR: Cannot convert {sum} to a float."));
@@ -1502,7 +1502,7 @@ impl FieldType {
15021502
return (TInteger, None);
15031503
}
15041504

1505-
if fast_float::parse::<f64, _>(string).is_ok() {
1505+
if string.parse::<f64>().is_ok() {
15061506
return (TFloat, None);
15071507
}
15081508
}
@@ -1679,7 +1679,7 @@ impl TypedMinMax {
16791679
match typ {
16801680
TString | TNull => {},
16811681
TFloat => {
1682-
let n = fast_float::parse::<f64, _>(from_utf8(sample).unwrap()).unwrap();
1682+
let n = from_utf8(sample).unwrap().parse::<f64>().unwrap();
16831683

16841684
self.floats.add(n);
16851685
self.integers.add(n as i64);

src/cmd/validate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -779,10 +779,10 @@ fn to_json_instance(
779779
},
780780
b'n' => {
781781
// number
782-
if let Ok(float) = fast_float::parse(&value_string) {
782+
if let Ok(float) = value_string.parse::<f64>() {
783783
json_object_map.insert(
784784
key_string,
785-
// safety: we know it's a valid f64 from the fast_float::parse() above
785+
// safety: we know it's a valid f64 from the parse() above
786786
Value::Number(Number::from_f64(float).unwrap()),
787787
);
788788
} else {

0 commit comments

Comments
 (0)