github-actions[bot] commented on code in PR #26822: URL: https://github.com/apache/doris/pull/26822#discussion_r1390331025
########## be/src/vec/common/int_exp.h: ########## @@ -68,16 +62,86 @@ namespace common { -inline constexpr std::int32_t exp10_i32(int x) { - return exp_details::get_exp<std::int32_t, 10, 10>(x); +constexpr inline int exp10_i32(int x) { + if (x < 0) return 0; + if (x > 9) return std::numeric_limits<int>::max(); + + constexpr int values[] = {1, 10, 100, 1000, 10000, Review Comment: warning: do not declare C-style arrays, use std::array<> instead [modernize-avoid-c-arrays] ```cpp constexpr int values[] = {1, 10, 100, 1000, 10000, ^ ``` ########## be/src/vec/common/int_exp.h: ########## @@ -68,16 +62,86 @@ namespace common { -inline constexpr std::int32_t exp10_i32(int x) { - return exp_details::get_exp<std::int32_t, 10, 10>(x); +constexpr inline int exp10_i32(int x) { + if (x < 0) return 0; + if (x > 9) return std::numeric_limits<int>::max(); + + constexpr int values[] = {1, 10, 100, 1000, 10000, + 100000, 1000000, 10000000, 100000000, 1000000000}; + return values[x]; } -inline constexpr std::int64_t exp10_i64(int x) { - return exp_details::get_exp<std::int64_t, 10, 19>(x); +constexpr inline int64_t exp10_i64(int x) { + if (x < 0) return 0; + if (x > 18) return std::numeric_limits<int64_t>::max(); + + constexpr int64_t values[] = {1LL, Review Comment: warning: do not declare C-style arrays, use std::array<> instead [modernize-avoid-c-arrays] ```cpp constexpr int64_t values[] = {1LL, ^ ``` ########## be/src/vec/common/int_exp.h: ########## @@ -68,16 +62,86 @@ inline uint64_t int_exp10(int x) { namespace common { -inline constexpr std::int32_t exp10_i32(int x) { - return exp_details::get_exp<std::int32_t, 10, 10>(x); +constexpr inline int exp10_i32(int x) { + if (x < 0) return 0; Review Comment: warning: statement should be inside braces [readability-braces-around-statements] ```suggestion if (x < 0) { return 0; } ``` ########## be/src/vec/common/int_exp.h: ########## @@ -68,16 +62,86 @@ namespace common { -inline constexpr std::int32_t exp10_i32(int x) { - return exp_details::get_exp<std::int32_t, 10, 10>(x); +constexpr inline int exp10_i32(int x) { + if (x < 0) return 0; + if (x > 9) return std::numeric_limits<int>::max(); + + constexpr int values[] = {1, 10, 100, 1000, 10000, + 100000, 1000000, 10000000, 100000000, 1000000000}; + return values[x]; } -inline constexpr std::int64_t exp10_i64(int x) { - return exp_details::get_exp<std::int64_t, 10, 19>(x); +constexpr inline int64_t exp10_i64(int x) { + if (x < 0) return 0; + if (x > 18) return std::numeric_limits<int64_t>::max(); + + constexpr int64_t values[] = {1LL, + 10LL, + 100LL, + 1000LL, + 10000LL, + 100000LL, + 1000000LL, + 10000000LL, + 100000000LL, + 1000000000LL, + 10000000000LL, + 100000000000LL, + 1000000000000LL, + 10000000000000LL, + 100000000000000LL, + 1000000000000000LL, + 10000000000000000LL, + 100000000000000000LL, + 1000000000000000000LL}; + return values[x]; } -inline constexpr __int128 exp10_i128(int x) { - return exp_details::get_exp<__int128, 10, 39>(x); +constexpr inline __int128 exp10_i128(int x) { + if (x < 0) return 0; + if (x > 38) return std::numeric_limits<__int128>::max(); + + constexpr __int128 values[] = { Review Comment: warning: do not declare C-style arrays, use std::array<> instead [modernize-avoid-c-arrays] ```cpp constexpr __int128 values[] = { ^ ``` ########## be/src/vec/common/int_exp.h: ########## @@ -68,16 +62,86 @@ namespace common { -inline constexpr std::int32_t exp10_i32(int x) { - return exp_details::get_exp<std::int32_t, 10, 10>(x); +constexpr inline int exp10_i32(int x) { + if (x < 0) return 0; + if (x > 9) return std::numeric_limits<int>::max(); + + constexpr int values[] = {1, 10, 100, 1000, 10000, + 100000, 1000000, 10000000, 100000000, 1000000000}; + return values[x]; } -inline constexpr std::int64_t exp10_i64(int x) { - return exp_details::get_exp<std::int64_t, 10, 19>(x); +constexpr inline int64_t exp10_i64(int x) { + if (x < 0) return 0; + if (x > 18) return std::numeric_limits<int64_t>::max(); + + constexpr int64_t values[] = {1LL, + 10LL, + 100LL, + 1000LL, + 10000LL, + 100000LL, + 1000000LL, + 10000000LL, + 100000000LL, + 1000000000LL, + 10000000000LL, + 100000000000LL, + 1000000000000LL, + 10000000000000LL, + 100000000000000LL, + 1000000000000000LL, + 10000000000000000LL, + 100000000000000000LL, + 1000000000000000000LL}; + return values[x]; } -inline constexpr __int128 exp10_i128(int x) { - return exp_details::get_exp<__int128, 10, 39>(x); +constexpr inline __int128 exp10_i128(int x) { + if (x < 0) return 0; Review Comment: warning: statement should be inside braces [readability-braces-around-statements] ```suggestion if (x < 0) { return 0; } ``` ########## be/src/vec/common/int_exp.h: ########## @@ -68,16 +62,86 @@ namespace common { -inline constexpr std::int32_t exp10_i32(int x) { - return exp_details::get_exp<std::int32_t, 10, 10>(x); +constexpr inline int exp10_i32(int x) { + if (x < 0) return 0; + if (x > 9) return std::numeric_limits<int>::max(); + + constexpr int values[] = {1, 10, 100, 1000, 10000, + 100000, 1000000, 10000000, 100000000, 1000000000}; + return values[x]; } -inline constexpr std::int64_t exp10_i64(int x) { - return exp_details::get_exp<std::int64_t, 10, 19>(x); +constexpr inline int64_t exp10_i64(int x) { + if (x < 0) return 0; Review Comment: warning: statement should be inside braces [readability-braces-around-statements] ```suggestion if (x < 0) { return 0; } ``` -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org