zeroshade commented on code in PR #43957:
URL: https://github.com/apache/arrow/pull/43957#discussion_r1773720710


##########
cpp/src/arrow/util/decimal.cc:
##########
@@ -521,6 +750,23 @@ std::string Decimal128::ToString(int32_t scale) const {
   return str;
 }
 
+static inline void ShiftAndAdd(std::string_view input, uint32_t* out) {
+  const uint32_t len =
+      static_cast<uint32_t>(std::min(kInt32DecimalDigits + 1, input.size()));
+  if (len == 0) {
+    return;
+  }
+
+  uint32_t value = 0;
+  ARROW_CHECK(internal::ParseValue<UInt32Type>(input.data(), len, &value));
+
+  uint64_t tmp = *out;
+  tmp *= kUInt32PowersOfTen[len];
+  tmp += value;
+
+  *out = static_cast<uint32_t>(tmp & 0xFFFFFFFFU);

Review Comment:
   `SimpleDecimalFromString` has the same overflow check for both Decimal32 and 
Decimal64 though? 
   
   that said, removing the `uint32_t` variant and just using the `uint64_t` 
variant does simplify this, so I'll do that.



-- 
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]

Reply via email to