alamb commented on a change in pull request #952:
URL: https://github.com/apache/arrow-rs/pull/952#discussion_r751183059
##########
File path: arrow/src/csv/reader.rs
##########
@@ -1614,7 +1605,7 @@ mod tests {
let result = parse_decimal_with_parameter(s, 20, 3);
assert_eq!(i, result.unwrap())
}
- let can_not_parse_tests = ["123,123", "."];
+ let can_not_parse_tests = ["123,123", ".", "123.123.123"];
Review comment:
๐
##########
File path: arrow/src/csv/reader.rs
##########
@@ -801,31 +800,23 @@ fn parse_decimal_with_parameter(s: &str, precision:
usize, scale: usize) -> Resu
}
};
+ // each byte is digitใ'-' or '.'
let bytes = s.as_bytes();
let mut negative = false;
let mut result: i128 = 0;
- while offset > 0 {
- match bytes[offset - 1] {
- b'-' => {
- negative = true;
- }
- b'.' => {
- // do nothing
- }
- b'0'..=b'9' => {
- result += i128::from(bytes[offset - 1] - b'0') * base;
- base *= 10;
- }
- _ => {
- return Err(ArrowError::ParseError(format!(
- "can't match byte {}",
- bytes[offset - 1]
- )));
- }
+ bytes[0..offset].iter().rev().for_each(|&byte| match byte {
Review comment:
๐ looking much nicer!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]