diff --git a/src/Functions/ReplaceRegexpImpl.h b/src/Functions/ReplaceRegexpImpl.h index bd8d90dcfe4..9f9a6f3bbd0 100644 --- a/src/Functions/ReplaceRegexpImpl.h +++ b/src/Functions/ReplaceRegexpImpl.h @@ -243,7 +243,7 @@ struct ReplaceRegexpImpl for (size_t i = 0; i < input_rows_count; ++i) { - size_t from = i > 0 ? haystack_offsets[i - 1] : 0; + size_t from = haystack_offsets[i - 1]; const char * hs_data = reinterpret_cast(haystack_data.data() + from); const size_t hs_length = static_cast(haystack_offsets[i] - from - 1); @@ -274,19 +274,19 @@ struct ReplaceRegexpImpl for (size_t i = 0; i < input_rows_count; ++i) { - size_t hs_from = i > 0 ? haystack_offsets[i - 1] : 0; + size_t hs_from = haystack_offsets[i - 1]; const char * hs_data = reinterpret_cast(haystack_data.data() + hs_from); const size_t hs_length = static_cast(haystack_offsets[i] - hs_from - 1); - size_t ndl_from = i > 0 ? needle_offsets[i - 1] : 0; + size_t ndl_from = needle_offsets[i - 1]; const char * ndl_data = reinterpret_cast(needle_data.data() + ndl_from); const size_t ndl_length = static_cast(needle_offsets[i] - ndl_from - 1); std::string_view needle(ndl_data, ndl_length); if (needle.empty()) { - memcpySmallAllowReadWriteOverflow15(&res_data[i > 0 ? res_offsets[i - 1] : 0], hs_data, hs_length + 1); - res_offsets[i] = (i > 0 ? res_offsets[i - 1] : 0) + hs_length + 1; + res_data.insert(res_data.end(), hs_data, hs_data + hs_length); + res_offsets[i] = res_offsets[i - 1] + hs_length + 1; continue; } @@ -336,11 +336,11 @@ struct ReplaceRegexpImpl for (size_t i = 0; i < input_rows_count; ++i) { - size_t hs_from = i > 0 ? haystack_offsets[i - 1] : 0; + size_t hs_from = haystack_offsets[i - 1]; const char * hs_data = reinterpret_cast(haystack_data.data() + hs_from); const size_t hs_length = static_cast(haystack_offsets[i] - hs_from - 1); - size_t repl_from = i > 0 ? replacement_offsets[i - 1] : 0; + size_t repl_from = replacement_offsets[i - 1]; const char * repl_data = reinterpret_cast(replacement_data.data() + repl_from); const size_t repl_length = static_cast(replacement_offsets[i] - repl_from - 1); std::string_view replacement(repl_data, repl_length); @@ -375,23 +375,23 @@ struct ReplaceRegexpImpl for (size_t i = 0; i < input_rows_count; ++i) { - size_t hs_from = i > 0 ? haystack_offsets[i - 1] : 0; + size_t hs_from = haystack_offsets[i - 1]; const char * hs_data = reinterpret_cast(haystack_data.data() + hs_from); const size_t hs_length = static_cast(haystack_offsets[i] - hs_from - 1); - size_t ndl_from = i > 0 ? needle_offsets[i - 1] : 0; + size_t ndl_from = needle_offsets[i - 1]; const char * ndl_data = reinterpret_cast(needle_data.data() + ndl_from); const size_t ndl_length = static_cast(needle_offsets[i] - ndl_from - 1); std::string_view needle(ndl_data, ndl_length); if (needle.empty()) { - memcpySmallAllowReadWriteOverflow15(&res_data[i > 0 ? res_offsets[i - 1] : 0], hs_data, hs_length + 1); - res_offsets[i] = (i > 0 ? res_offsets[i - 1] : 0) + hs_length + 1; + res_data.insert(res_data.end(), hs_data, hs_data + hs_length); + res_offsets[i] = res_offsets[i - 1] + hs_length + 1; continue; } - size_t repl_from = i > 0 ? replacement_offsets[i - 1] : 0; + size_t repl_from = replacement_offsets[i - 1]; const char * repl_data = reinterpret_cast(replacement_data.data() + repl_from); const size_t repl_length = static_cast(replacement_offsets[i] - repl_from - 1); std::string_view replacement(repl_data, repl_length);