Skip to content

Commit

Permalink
stats: use atoi to skip utf8 validation to directly convert &[u8] t…
Browse files Browse the repository at this point in the history
…o integer
  • Loading branch information
jqnatividad committed Nov 14, 2023
1 parent dfabd62 commit 69bfbe3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/cmd/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,8 @@ impl Stats {
};
}
},
// do nothing for String type
TString => {},
TFloat | TInteger => {
if sample_type == TNull {
if self.which.include_nulls {
Expand All @@ -1069,8 +1071,6 @@ impl Stats {
}
}
},
// do nothing for String type
TString => {},
TDateTime | TDate => {
if sample_type == TNull {
if self.which.include_nulls {
Expand Down Expand Up @@ -1612,7 +1612,7 @@ impl TypedSum {
// so we don't panic on overflow/underflow, use saturating_add
self.integer = self
.integer
.saturating_add(from_bytes::<i64>(sample).unwrap());
.saturating_add(atoi::atoi::<i64>(sample).unwrap());
}
},
_ => {},
Expand Down Expand Up @@ -1685,13 +1685,13 @@ impl TypedMinMax {
self.integers.add(n as i64);
},
TInteger => {
let n = from_utf8(sample).unwrap().parse::<i64>().unwrap();
let n = atoi::atoi::<i64>(sample).unwrap();
self.integers.add(n);
#[allow(clippy::cast_precision_loss)]
self.floats.add(n as f64);
},
TDate | TDateTime => {
let n = from_utf8(sample).unwrap().parse::<i64>().unwrap();
let n = atoi::atoi::<i64>(sample).unwrap();
self.dates.add(n);
},
}
Expand Down

0 comments on commit 69bfbe3

Please sign in to comment.