viirya commented on code in PR #3734:
URL: https://github.com/apache/arrow-rs/pull/3734#discussion_r1112224836
##########
arrow-csv/src/reader/mod.rs:
##########
@@ -866,21 +866,24 @@ fn parse_decimal_with_parameter<T: DecimalType>(
let mut negative = false;
let mut result = T::Native::usize_as(0);
- for byte in bytes[0..offset].iter().rev() {
- match byte {
- b'-' => {
- negative = true;
- }
- b'0'..=b'9' => {
- let add =
- T::Native::usize_as((byte - b'0') as
usize).mul_checked(base)?;
- result = result.add_checked(add)?;
- base = base.mul_checked(T::Native::usize_as(10))?;
+ bytes[0..offset]
+ .iter()
+ .rev()
+ .try_for_each::<_, Result<(), ArrowError>>(|&byte| {
+ match byte {
+ b'-' => {
+ negative = true;
+ }
+ b'0'..=b'9' => {
+ let add = T::Native::usize_as((byte - b'0') as usize)
+ .mul_checked(base)?;
+ result = result.add_checked(add)?;
+ base = base.mul_checked(T::Native::usize_as(10))?;
+ }
+ _ => (),
}
- // because of the PARSE_DECIMAL_RE, bytes just contains
digit、'-' and '.'.
Review Comment:
No need to keep the comment?
--
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]