Skip to content

Commit

Permalink
remove fast-float crate as std float parse is now also using Eisel-Le…
Browse files Browse the repository at this point in the history
…mire algorithm

rust-lang/rust#86761
  • Loading branch information
jqnatividad committed Nov 13, 2023
1 parent 723443e commit 0520894
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 19 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ eudex = { version = "0.1", optional = true }
ext-sort = { version = "0.1", features = [
"memory-limit",
], default-features = false }
fast-float = "0.2"
fastrand = "2"
flate2 = { version = "1", optional = true }
file-format = { version = "0.22", features = ["reader"] }
Expand Down
10 changes: 4 additions & 6 deletions src/cmd/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ fn apply_operations(
*cell = censor.count(cell).to_string();
},
Operations::Thousands => {
if let Ok(num) = fast_float::parse::<f64, _>(&cell) {
if let Ok(num) = cell.parse::<f64>() {
let mut temp_string = num.separate_by_policy(*THOUSANDS_POLICY.get().unwrap());

// if there is a decimal separator (fractional part > 0.0), use the requested
Expand All @@ -1131,7 +1131,7 @@ fn apply_operations(
}
},
Operations::Round => {
if let Ok(num) = fast_float::parse::<f64, _>(&cell) {
if let Ok(num) = cell.parse::<f64>() {
*cell = util::round_num(num, *ROUND_PLACES.get().unwrap());
}
},
Expand Down Expand Up @@ -1172,10 +1172,8 @@ fn apply_operations(
};

if let Ok(currency_value) = Currency::from_str(&cell_val) {
let currency_wrk = currency_value.convert(
fast_float::parse::<f64, _>(replacement).unwrap_or(1.0_f64),
comparand,
);
let currency_wrk = currency_value
.convert(replacement.parse::<f64>().unwrap_or(1.0_f64), comparand);
*cell = if formatstr.contains("euro") {
format!("{currency_wrk:e}")
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/applydp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ fn applydp_operations(
*cell = regexreplace.replace_all(cell, replacement).to_string();
},
Operations::Round => {
if let Ok(num) = fast_float::parse(&cell) {
if let Ok(num) = cell.parse::<f64>() {
*cell = util::round_num(num, *ROUND_PLACES.get().unwrap());
}
},
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/geocode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1529,8 +1529,8 @@ fn search_index(

let loccaps = locregex.captures(cell);
if let Some(loccaps) = loccaps {
let lat = fast_float::parse(&loccaps[1]).unwrap_or_default();
let long = fast_float::parse(&loccaps[2]).unwrap_or_default();
let lat = loccaps[1].to_string().parse::<f32>().unwrap_or_default();
let long = loccaps[2].to_string().parse::<f32>().unwrap_or_default();
if (-90.0..=90.0).contains(&lat) && (-180.0..=180.0).contains(&long) {
let search_result = engine.reverse((lat, long), 1, k, country_filter_list.as_deref());
let Some(cityrecord) = (match search_result {
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,15 +353,15 @@ pub fn infer_schema_from_stats(args: &Args, input_filename: &str) -> CliResult<M
type_list.push(Value::String("number".to_string()));

if let Some(min_str) = stats_record.get(stats_col_index_map["min"]) {
let min = fast_float::parse::<f64, _>(min_str).unwrap();
let min = min_str.parse::<f64>().unwrap();
field_map.insert(
"minimum".to_string(),
Value::Number(Number::from_f64(min).unwrap()),
);
};

if let Some(max_str) = stats_record.get(stats_col_index_map["max"]) {
let max = fast_float::parse::<f64, _>(max_str).unwrap();
let max = max_str.parse::<f64>().unwrap();
field_map.insert(
"maximum".to_string(),
Value::Number(Number::from_f64(max).unwrap()),
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ where
.and_then(|s| {
if let Ok(i) = s.parse::<i64>() {
Some(Number::Int(i))
} else if let Ok(f) = fast_float::parse(s) {
} else if let Ok(f) = s.parse::<f64>() {
Some(Number::Float(f))
} else {
None
Expand Down
6 changes: 3 additions & 3 deletions src/cmd/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,7 @@ impl Stats {
// sum
if let Some(sum) = self.sum.as_ref().and_then(|sum| sum.show(typ)) {
if typ == FieldType::TFloat {
if let Ok(f64_val) = fast_float::parse::<f64, _>(&sum) {
if let Ok(f64_val) = sum.parse::<f64>() {
pieces.push(util::round_num(f64_val, round_places));
} else {
pieces.push(format!("ERROR: Cannot convert {sum} to a float."));
Expand Down Expand Up @@ -1502,7 +1502,7 @@ impl FieldType {
return (TInteger, None);
}

if fast_float::parse::<f64, _>(string).is_ok() {
if string.parse::<f64>().is_ok() {
return (TFloat, None);
}
}
Expand Down Expand Up @@ -1679,7 +1679,7 @@ impl TypedMinMax {
match typ {
TString | TNull => {},
TFloat => {
let n = fast_float::parse::<f64, _>(from_utf8(sample).unwrap()).unwrap();
let n = from_utf8(sample).unwrap().parse::<f64>().unwrap();

self.floats.add(n);
self.integers.add(n as i64);
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -779,10 +779,10 @@ fn to_json_instance(
},
b'n' => {
// number
if let Ok(float) = fast_float::parse(&value_string) {
if let Ok(float) = value_string.parse::<f64>() {
json_object_map.insert(
key_string,
// safety: we know it's a valid f64 from the fast_float::parse() above
// safety: we know it's a valid f64 from the parse() above
Value::Number(Number::from_f64(float).unwrap()),
);
} else {
Expand Down

0 comments on commit 0520894

Please sign in to comment.