Skip to content

Commit

Permalink
Optimized how current_string is created for each substring
Browse files Browse the repository at this point in the history
  • Loading branch information
SharafMohamed committed Jul 8, 2024
1 parent 53d6242 commit b3efd94
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions components/core/src/clp/Grep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1016,9 +1016,10 @@ void Grep::generate_query_substring_logtypes(
// with the last entry having all possible logtypes for the full query itself.
for (uint32_t i = 0; i < processed_search_string.size(); i++) {
for (uint32_t j = 0; j <= i; ++j) {
std::string current_string = processed_search_string.substr(j, i - j + 1);
std::vector<QueryLogtype> possible_substring_types;
if (current_string == "*") {
std::string_view substr
= std::string_view(processed_search_string).substr(j, i - j + 1);
if (substr == "*") {
possible_substring_types.emplace_back('*', "*", false);
} else {
set<uint32_t> variable_types;
Expand All @@ -1030,14 +1031,16 @@ void Grep::generate_query_substring_logtypes(
// If we decompose the string into either substrings "* ","ab*","cd"," *" or
// "* ","ab","*cd"," *", neither would capture the possibility of a logtype with the
// form "* <has#><has#> *", which is a valid possibility during compression.
std::string current_string;
bool prev_star = j > 0 && processed_search_string[j - 1] == '*';
bool next_star = i < processed_search_string.back() - 1
&& processed_search_string[i + 1] == '*';
if (prev_star) {
current_string.insert(0, "*");
current_string += "*";
}
current_string += substr;
if (next_star) {
current_string.push_back('*');
current_string += "*";
}

// If the substring contains a wildcard, we need a different approach to determine
Expand Down

0 comments on commit b3efd94

Please sign in to comment.