From 71b491fb3d2591447e7c57ffc7a53dbd549bb62e Mon Sep 17 00:00:00 2001 From: gibber9809 Date: Wed, 27 Aug 2025 18:22:15 +0000 Subject: [PATCH 1/2] Delete unused StringUtils methods; Remove unused includes of Utils.hpp --- components/core/src/clp_s/DictionaryEntry.cpp | 1 - components/core/src/clp_s/Utils.cpp | 50 ------------------- components/core/src/clp_s/Utils.hpp | 48 ------------------ 3 files changed, 99 deletions(-) diff --git a/components/core/src/clp_s/DictionaryEntry.cpp b/components/core/src/clp_s/DictionaryEntry.cpp index a7ab237e2c..02cec0a4da 100644 --- a/components/core/src/clp_s/DictionaryEntry.cpp +++ b/components/core/src/clp_s/DictionaryEntry.cpp @@ -12,7 +12,6 @@ #include "../clp/ir/parsing.hpp" #include "../clp/ir/types.hpp" #include "../clp/type_utils.hpp" -#include "Utils.hpp" using clp::EncodedVariableInterpreter; using clp::enum_to_underlying_type; diff --git a/components/core/src/clp_s/Utils.cpp b/components/core/src/clp_s/Utils.cpp index d278daca63..df5e534392 100644 --- a/components/core/src/clp_s/Utils.cpp +++ b/components/core/src/clp_s/Utils.cpp @@ -163,56 +163,6 @@ bool UriUtils::get_last_uri_component(std::string_view const uri, std::string& n return true; } -bool StringUtils::get_bounds_of_next_var(string const& msg, size_t& begin_pos, size_t& end_pos) { - auto const msg_length = msg.length(); - if (end_pos >= msg_length) { - return false; - } - - while (true) { - begin_pos = end_pos; - // Find next non-delimiter - for (; begin_pos < msg_length; ++begin_pos) { - if (false == is_delim(msg[begin_pos])) { - break; - } - } - if (msg_length == begin_pos) { - // Early exit for performance - return false; - } - - bool contains_decimal_digit = false; - bool contains_alphabet = false; - - // Find next delimiter - end_pos = begin_pos; - for (; end_pos < msg_length; ++end_pos) { - char c = msg[end_pos]; - if (clp::string_utils::is_decimal_digit(c)) { - contains_decimal_digit = true; - } else if (clp::string_utils::is_alphabet(c)) { - contains_alphabet = true; - } else if (is_delim(c)) { - break; - } - } - - // Treat token as variable if: - // - it contains a decimal digit, or - // - it's directly preceded by an equals sign and contains an alphabet, or - // - it could be a multi-digit hex value - if (contains_decimal_digit - || (begin_pos > 0 && '=' == msg[begin_pos - 1] && contains_alphabet) - || could_be_multi_digit_hex_value(msg, begin_pos, end_pos)) - { - break; - } - } - - return (msg_length != begin_pos); -} - void StringUtils::escape_json_string(std::string& destination, std::string_view const source) { // Escaping is implemented using this `append_unescaped_slice` approach to offer a fast path // when strings are mostly or entirely valid escaped JSON. Benchmarking shows that this offers diff --git a/components/core/src/clp_s/Utils.hpp b/components/core/src/clp_s/Utils.hpp index 2537137e68..a711eb8ad6 100644 --- a/components/core/src/clp_s/Utils.hpp +++ b/components/core/src/clp_s/Utils.hpp @@ -65,54 +65,6 @@ class UriUtils { class StringUtils { public: - /** - * Checks if character is a hexadecimal (base-16) digit - * @param c - * @return true if c is a hexadecimal digit, false otherwise - */ - static inline bool is_delim(char c) { - return !( - '+' == c || ('-' <= c && c <= '9') || ('A' <= c && c <= 'Z') || '\\' == c - || '_' == c || ('a' <= c && c <= 'z') - ); - } - - /** - * Checks if the string could be a hexadecimal value - * @param str - * @param begin_pos - * @param end_pos - * @return true if str could be a hexadecimal value, false otherwise - */ - static inline bool - could_be_multi_digit_hex_value(std::string const& str, size_t begin_pos, size_t end_pos) { - if (end_pos - begin_pos < 2) { - return false; - } - - for (size_t i = begin_pos; i < end_pos; ++i) { - auto c = str[i]; - if (false - == (('a' <= c && c <= 'f') || ('A' <= c && c <= 'F') || ('0' <= c && c <= '9'))) - { - return false; - } - } - - return true; - } - - /** - * Returns bounds of next variable in given string - * A variable is a token (word between two delimiters) that contains numbers or is directly - * preceded by an equals sign - * @param msg - * @param begin_pos Begin position of last variable, changes to begin position of next variable - * @param end_pos End position of last variable, changes to end position of next variable - * @return true if a variable was found, false otherwise - */ - static bool get_bounds_of_next_var(std::string const& msg, size_t& begin_pos, size_t& end_pos); - /** * Escapes a string according to JSON string escaping rules and appends the escaped string to * a buffer. The input string can be either ascii or UTF-8. From 799688d8743928f23eca150710d988f83cf6b8fe Mon Sep 17 00:00:00 2001 From: gibber9809 Date: Wed, 27 Aug 2025 18:46:36 +0000 Subject: [PATCH 2/2] Remove more unused includes of Utils.hpp --- components/core/src/clp_s/ArchiveReader.hpp | 1 - components/core/src/clp_s/DictionaryReader.hpp | 1 - components/core/src/clp_s/JsonParser.hpp | 1 - components/core/src/clp_s/Schema.hpp | 1 - components/core/src/clp_s/TimestampDictionaryWriter.cpp | 2 -- components/core/src/clp_s/clp-s.cpp | 2 -- components/core/src/clp_s/search/QueryRunner.cpp | 1 + 7 files changed, 1 insertion(+), 8 deletions(-) diff --git a/components/core/src/clp_s/ArchiveReader.hpp b/components/core/src/clp_s/ArchiveReader.hpp index 41a64cf503..40cee82bb5 100644 --- a/components/core/src/clp_s/ArchiveReader.hpp +++ b/components/core/src/clp_s/ArchiveReader.hpp @@ -15,7 +15,6 @@ #include "SchemaReader.hpp" #include "search/Projection.hpp" #include "TimestampDictionaryReader.hpp" -#include "Utils.hpp" namespace clp_s { class ArchiveReader { diff --git a/components/core/src/clp_s/DictionaryReader.hpp b/components/core/src/clp_s/DictionaryReader.hpp index e5a8a92829..05e81ee7bd 100644 --- a/components/core/src/clp_s/DictionaryReader.hpp +++ b/components/core/src/clp_s/DictionaryReader.hpp @@ -14,7 +14,6 @@ #include "ArchiveReaderAdaptor.hpp" #include "DictionaryEntry.hpp" -#include "Utils.hpp" namespace clp_s { template diff --git a/components/core/src/clp_s/JsonParser.hpp b/components/core/src/clp_s/JsonParser.hpp index a5718a1a57..05e29641b0 100644 --- a/components/core/src/clp_s/JsonParser.hpp +++ b/components/core/src/clp_s/JsonParser.hpp @@ -28,7 +28,6 @@ #include "SchemaTree.hpp" #include "SchemaWriter.hpp" #include "TimestampDictionaryWriter.hpp" -#include "Utils.hpp" #include "ZstdCompressor.hpp" using namespace simdjson; diff --git a/components/core/src/clp_s/Schema.hpp b/components/core/src/clp_s/Schema.hpp index b16cca0986..8dd6214360 100644 --- a/components/core/src/clp_s/Schema.hpp +++ b/components/core/src/clp_s/Schema.hpp @@ -8,7 +8,6 @@ #include "SchemaTree.hpp" #include "TraceableException.hpp" -#include "Utils.hpp" namespace clp_s { /** diff --git a/components/core/src/clp_s/TimestampDictionaryWriter.cpp b/components/core/src/clp_s/TimestampDictionaryWriter.cpp index c4550d568c..0c62a1964e 100644 --- a/components/core/src/clp_s/TimestampDictionaryWriter.cpp +++ b/components/core/src/clp_s/TimestampDictionaryWriter.cpp @@ -4,8 +4,6 @@ #include #include -#include "Utils.hpp" - namespace clp_s { void TimestampDictionaryWriter::write_timestamp_entries( std::map const& ranges, diff --git a/components/core/src/clp_s/clp-s.cpp b/components/core/src/clp_s/clp-s.cpp index 84611dc3c7..93f7299414 100644 --- a/components/core/src/clp_s/clp-s.cpp +++ b/components/core/src/clp_s/clp-s.cpp @@ -38,7 +38,6 @@ #include "search/Projection.hpp" #include "search/SchemaMatch.hpp" #include "TimestampPattern.hpp" -#include "Utils.hpp" using namespace clp_s::search; using clp_s::cArchiveFormatDevelopmentVersionFlag; @@ -47,7 +46,6 @@ using clp_s::cEpochTimeMin; using clp_s::CommandLineArguments; using clp_s::KvIrSearchError; using clp_s::KvIrSearchErrorEnum; -using clp_s::StringUtils; namespace { /** diff --git a/components/core/src/clp_s/search/QueryRunner.cpp b/components/core/src/clp_s/search/QueryRunner.cpp index 4b874853a7..bc862fbe5b 100644 --- a/components/core/src/clp_s/search/QueryRunner.cpp +++ b/components/core/src/clp_s/search/QueryRunner.cpp @@ -11,6 +11,7 @@ #include "../../clp/Query.hpp" #include "../../clp/type_utils.hpp" #include "../SchemaTree.hpp" +#include "../Utils.hpp" #include "ast/AndExpr.hpp" #include "ast/ColumnDescriptor.hpp" #include "ast/Expression.hpp"