From 1a2bdf14fa408079217c9b4326086fbc1b94e8f4 Mon Sep 17 00:00:00 2001 From: Roman Vasin Date: Thu, 1 Dec 2022 14:09:37 +0000 Subject: [PATCH] Small refactor: renaming various vars --- src/Functions/URL/cutURLParameter.cpp | 31 +++++++++++++-------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/Functions/URL/cutURLParameter.cpp b/src/Functions/URL/cutURLParameter.cpp index 72991575d4a..bb4c02df725 100644 --- a/src/Functions/URL/cutURLParameter.cpp +++ b/src/Functions/URL/cutURLParameter.cpp @@ -59,16 +59,16 @@ public: const ColumnPtr column_needle = arguments[1].column; const ColumnConst * col_needle = typeid_cast(&*column_needle); - const ColumnArray * col_const_array = checkAndGetColumnConstData(column_needle.get()); + const ColumnArray * col_needle_const_array = checkAndGetColumnConstData(column_needle.get()); - if (!col_needle && !col_const_array) + if (!col_needle && !col_needle_const_array) throw Exception(ErrorCodes::ILLEGAL_COLUMN, "Second argument of function {} must be constant string or constant array", getName()); - if (col_const_array) + if (col_needle_const_array) { - if (col_const_array->getData().size() > 0 && typeid_cast(*arguments[1].type).getNestedType()->getTypeId() != TypeIndex::String) + if (!col_needle_const_array->getData().empty() && typeid_cast(*arguments[1].type).getNestedType()->getTypeId() != TypeIndex::String) throw Exception(ErrorCodes::ILLEGAL_COLUMN, "Second argument of function {} must be constant array of strings", getName()); @@ -80,7 +80,7 @@ public: ColumnString::Chars & vec_res = col_res->getChars(); ColumnString::Offsets & offsets_res = col_res->getOffsets(); - vector(col->getChars(), col->getOffsets(), col_needle, col_const_array, vec_res, offsets_res); + vector(col->getChars(), col->getOffsets(), col_needle, col_needle_const_array, vec_res, offsets_res); return col_res; } else @@ -89,7 +89,7 @@ public: arguments[0].column->getName(), getName()); } - static void cutURL(ColumnString::Chars & data, std::string pattern, size_t prev_offset, size_t & cur_offset, size_t & offset_adjust) + static void cutURL(ColumnString::Chars & data, String pattern, size_t prev_offset, size_t & cur_offset, size_t & offset_adjust) { pattern += '='; const char * param_str = pattern.c_str(); @@ -139,7 +139,7 @@ public: static void vector(const ColumnString::Chars & data, const ColumnString::Offsets & offsets, const ColumnConst * col_needle, - const ColumnArray * col_const_array, + const ColumnArray * col_needle_const_array, ColumnString::Chars & res_data, ColumnString::Offsets & res_offsets) { res_data.resize(data.size()); @@ -154,19 +154,18 @@ public: { cur_offset = offsets[i] - offset_adjust; - if (!col_const_array) + if (col_needle_const_array) { - cutURL(res_data, col_needle->getValue(), prev_offset, cur_offset, offset_adjust); + size_t num_needles = col_needle_const_array->getData().size(); + for (size_t j = 0; j < num_needles; ++j) + { + auto field = col_needle_const_array->getData()[j]; + cutURL(res_data, field.get(), prev_offset, cur_offset, offset_adjust); + } } else { - size_t data_size = col_const_array->getData().size(); - - for (size_t j = 0; j < data_size; ++j) - { - auto field = col_const_array->getData()[j]; - cutURL(res_data, field.get(), prev_offset, cur_offset, offset_adjust); - } + cutURL(res_data, col_needle->getValue(), prev_offset, cur_offset, offset_adjust); } res_offsets[i] = cur_offset; prev_offset = cur_offset;