From c1271796a5a80fbdab9a9c5a5913fcc2036e6cf6 Mon Sep 17 00:00:00 2001 From: qidaye Date: Thu, 20 Feb 2025 15:49:40 +0800 Subject: [PATCH] [opt]Avoid repeated calculations of suffix paths --- be/src/olap/tablet_schema.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/be/src/olap/tablet_schema.cpp b/be/src/olap/tablet_schema.cpp index 82bc268d6a3497..51e5a8dd179bf1 100644 --- a/be/src/olap/tablet_schema.cpp +++ b/be/src/olap/tablet_schema.cpp @@ -1407,11 +1407,11 @@ bool TabletSchema::has_inverted_index_with_index_id(int64_t index_id) const { const TabletIndex* TabletSchema::inverted_index(int32_t col_unique_id, const std::string& suffix_path) const { + const std::string escaped_suffix = escape_for_path_name(suffix_path); for (size_t i = 0; i < _indexes.size(); i++) { if (_indexes[i].index_type() == IndexType::INVERTED) { for (int32_t id : _indexes[i].col_unique_ids()) { - if (id == col_unique_id && - _indexes[i].get_index_suffix() == escape_for_path_name(suffix_path)) { + if (id == col_unique_id && _indexes[i].get_index_suffix() == escaped_suffix) { return &(_indexes[i]); } }