Fill a buffer with repeated fill_text using O(log n) doubling strategy
| 2115 | |
| 2116 | // Fill a buffer with repeated fill_text using O(log n) doubling strategy |
| 2117 | static FORCE_INLINE void fill_buffer_with_pattern(gdv_binary dest, |
| 2118 | gdv_int32 total_fill_bytes, |
| 2119 | const char* fill_text, |
| 2120 | gdv_int32 fill_text_len) { |
| 2121 | gdv_int32 initial_copy = std::min(fill_text_len, total_fill_bytes); |
| 2122 | memcpy(dest, fill_text, initial_copy); |
| 2123 | gdv_int32 written = initial_copy; |
| 2124 | while (written * 2 <= total_fill_bytes) { |
| 2125 | memcpy(dest + written, dest, written); |
| 2126 | written *= 2; |
| 2127 | } |
| 2128 | if (written < total_fill_bytes) { |
| 2129 | memcpy(dest + written, dest, total_fill_bytes - written); |
| 2130 | } |
| 2131 | } |
| 2132 | |
| 2133 | FORCE_INLINE |
| 2134 | const char* lpad_utf8_int32_utf8(gdv_int64 context, const char* text, gdv_int32 text_len, |
no outgoing calls
no test coverage detected