yiguolei commented on code in PR #54807:
URL: https://github.com/apache/doris/pull/54807#discussion_r2281121546
##########
be/src/util/jsonb_stream.h:
##########
@@ -144,16 +141,18 @@ class JsonbOutStream : public std::ostream {
size_ += result.size;
}
- // write the double to string
- void write(double d) {
+ // write the double/float to string
+ template <typename T>
+ requires(std::is_floating_point_v<T>)
+ void write(T d) {
// snprintf automatically adds a NULL, so we need one more char
if (size_ + MAX_DOUBLE_DIGITS + 1 > capacity_) {
realloc(MAX_DOUBLE_DIGITS + 1);
}
- int len = snprintf(head_ + size_, MAX_DOUBLE_DIGITS + 1, "%.15g", d);
- assert(len > 0);
- size_ += len;
+ const auto result = fmt::format_to_n(head_ + size_, MAX_DOUBLE_DIGITS
+ 1, "{}", d);
Review Comment:
等等我们统一的to string 实现之后,再改这个PR吧
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]