github-actions[bot] commented on code in PR #27342:
URL: https://github.com/apache/doris/pull/27342#discussion_r1400420461


##########
be/src/vec/common/format_ip.cpp:
##########
@@ -75,4 +76,123 @@ consteval std::array<std::pair<const char*, size_t>, N> 
str_make_array() {
 /// This will generate static array of pair<const char *, size_t> for [0..255] 
at compile time
 extern constexpr std::array<std::pair<const char*, size_t>, 256> 
one_byte_to_string_lookup_table =
         str_make_array<256>();
+
+/// integer logarithm, return ceil(log(value, base)) (the smallest integer 
greater or equal than log(value, base)
+static constexpr UInt32 intLog(const UInt32 value, const UInt32 base, const 
bool carry) {
+    return value >= base ? 1 + intLog(value / base, base, value % base || 
carry)
+                         : value % base > 1 || carry;
+}
+
+/// Print integer in desired base, faster than sprintf.
+/// NOTE This is not the best way. See 
https://github.com/miloyip/itoa-benchmark
+/// But it doesn't matter here.
+template <UInt32 base, typename T>
+static void print_integer(char*& out, T value) {
+    if (value == 0) {
+        *out++ = '0';
+    } else {
+        constexpr size_t buffer_size = sizeof(T) * intLog(256, base, false);
+
+        char buf[buffer_size];
+        auto ptr = buf;
+
+        while (value > 0) {
+            *ptr = hex_digit_lowercase(value % base);
+            ++ptr;
+            value /= base;
+        }
+
+        /// Copy to out reversed.
+        while (ptr != buf) {
+            --ptr;
+            *out = *ptr;
+            ++out;
+        }
+    }
+}
+
+void formatIPv6(const unsigned char* src, char*& dst, uint8_t 
zeroed_tail_bytes_count) {

Review Comment:
   warning: function 'formatIPv6' exceeds recommended size/complexity 
thresholds [readability-function-size]
   ```cpp
   void formatIPv6(const unsigned char* src, char*& dst, uint8_t 
zeroed_tail_bytes_count) {
        ^
   ```
   <details>
   <summary>Additional context</summary>
   
   **be/src/vec/common/format_ip.cpp:113:** 82 lines including whitespace and 
comments (threshold 80)
   ```cpp
   void formatIPv6(const unsigned char* src, char*& dst, uint8_t 
zeroed_tail_bytes_count) {
        ^
   ```
   
   </details>
   



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

Reply via email to