Skip to content

Commit a1382e3

Browse files
authored
refactor(clp-s): Delete unused clp_s::StringUtils functions; Remove unused Utils.hpp includes. (#1269)
1 parent bfd4f60 commit a1382e3

File tree

10 files changed

+1
-107
lines changed

10 files changed

+1
-107
lines changed

components/core/src/clp_s/ArchiveReader.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include "SchemaReader.hpp"
1616
#include "search/Projection.hpp"
1717
#include "TimestampDictionaryReader.hpp"
18-
#include "Utils.hpp"
1918

2019
namespace clp_s {
2120
class ArchiveReader {

components/core/src/clp_s/DictionaryEntry.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "../clp/ir/parsing.hpp"
1313
#include "../clp/ir/types.hpp"
1414
#include "../clp/type_utils.hpp"
15-
#include "Utils.hpp"
1615

1716
using clp::EncodedVariableInterpreter;
1817
using clp::enum_to_underlying_type;

components/core/src/clp_s/DictionaryReader.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
#include "ArchiveReaderAdaptor.hpp"
1616
#include "DictionaryEntry.hpp"
17-
#include "Utils.hpp"
1817

1918
namespace clp_s {
2019
template <typename DictionaryIdType, typename EntryType>

components/core/src/clp_s/JsonParser.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include "SchemaTree.hpp"
2929
#include "SchemaWriter.hpp"
3030
#include "TimestampDictionaryWriter.hpp"
31-
#include "Utils.hpp"
3231
#include "ZstdCompressor.hpp"
3332

3433
namespace clp_s {

components/core/src/clp_s/Schema.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#include "SchemaTree.hpp"
1010
#include "TraceableException.hpp"
11-
#include "Utils.hpp"
1211

1312
namespace clp_s {
1413
/**

components/core/src/clp_s/TimestampDictionaryWriter.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
#include <sstream>
55
#include <string_view>
66

7-
#include "Utils.hpp"
8-
97
namespace clp_s {
108
void TimestampDictionaryWriter::write_timestamp_entries(
119
std::map<std::string, TimestampEntry> const& ranges,

components/core/src/clp_s/Utils.cpp

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -163,56 +163,6 @@ bool UriUtils::get_last_uri_component(std::string_view const uri, std::string& n
163163
return true;
164164
}
165165

166-
bool StringUtils::get_bounds_of_next_var(string const& msg, size_t& begin_pos, size_t& end_pos) {
167-
auto const msg_length = msg.length();
168-
if (end_pos >= msg_length) {
169-
return false;
170-
}
171-
172-
while (true) {
173-
begin_pos = end_pos;
174-
// Find next non-delimiter
175-
for (; begin_pos < msg_length; ++begin_pos) {
176-
if (false == is_delim(msg[begin_pos])) {
177-
break;
178-
}
179-
}
180-
if (msg_length == begin_pos) {
181-
// Early exit for performance
182-
return false;
183-
}
184-
185-
bool contains_decimal_digit = false;
186-
bool contains_alphabet = false;
187-
188-
// Find next delimiter
189-
end_pos = begin_pos;
190-
for (; end_pos < msg_length; ++end_pos) {
191-
char c = msg[end_pos];
192-
if (clp::string_utils::is_decimal_digit(c)) {
193-
contains_decimal_digit = true;
194-
} else if (clp::string_utils::is_alphabet(c)) {
195-
contains_alphabet = true;
196-
} else if (is_delim(c)) {
197-
break;
198-
}
199-
}
200-
201-
// Treat token as variable if:
202-
// - it contains a decimal digit, or
203-
// - it's directly preceded by an equals sign and contains an alphabet, or
204-
// - it could be a multi-digit hex value
205-
if (contains_decimal_digit
206-
|| (begin_pos > 0 && '=' == msg[begin_pos - 1] && contains_alphabet)
207-
|| could_be_multi_digit_hex_value(msg, begin_pos, end_pos))
208-
{
209-
break;
210-
}
211-
}
212-
213-
return (msg_length != begin_pos);
214-
}
215-
216166
void StringUtils::escape_json_string(std::string& destination, std::string_view const source) {
217167
// Escaping is implemented using this `append_unescaped_slice` approach to offer a fast path
218168
// when strings are mostly or entirely valid escaped JSON. Benchmarking shows that this offers

components/core/src/clp_s/Utils.hpp

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -65,54 +65,6 @@ class UriUtils {
6565

6666
class StringUtils {
6767
public:
68-
/**
69-
* Checks if character is a hexadecimal (base-16) digit
70-
* @param c
71-
* @return true if c is a hexadecimal digit, false otherwise
72-
*/
73-
static inline bool is_delim(char c) {
74-
return !(
75-
'+' == c || ('-' <= c && c <= '9') || ('A' <= c && c <= 'Z') || '\\' == c
76-
|| '_' == c || ('a' <= c && c <= 'z')
77-
);
78-
}
79-
80-
/**
81-
* Checks if the string could be a hexadecimal value
82-
* @param str
83-
* @param begin_pos
84-
* @param end_pos
85-
* @return true if str could be a hexadecimal value, false otherwise
86-
*/
87-
static inline bool
88-
could_be_multi_digit_hex_value(std::string const& str, size_t begin_pos, size_t end_pos) {
89-
if (end_pos - begin_pos < 2) {
90-
return false;
91-
}
92-
93-
for (size_t i = begin_pos; i < end_pos; ++i) {
94-
auto c = str[i];
95-
if (false
96-
== (('a' <= c && c <= 'f') || ('A' <= c && c <= 'F') || ('0' <= c && c <= '9')))
97-
{
98-
return false;
99-
}
100-
}
101-
102-
return true;
103-
}
104-
105-
/**
106-
* Returns bounds of next variable in given string
107-
* A variable is a token (word between two delimiters) that contains numbers or is directly
108-
* preceded by an equals sign
109-
* @param msg
110-
* @param begin_pos Begin position of last variable, changes to begin position of next variable
111-
* @param end_pos End position of last variable, changes to end position of next variable
112-
* @return true if a variable was found, false otherwise
113-
*/
114-
static bool get_bounds_of_next_var(std::string const& msg, size_t& begin_pos, size_t& end_pos);
115-
11668
/**
11769
* Escapes a string according to JSON string escaping rules and appends the escaped string to
11870
* a buffer. The input string can be either ascii or UTF-8.

components/core/src/clp_s/clp-s.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#include "search/Projection.hpp"
3939
#include "search/SchemaMatch.hpp"
4040
#include "TimestampPattern.hpp"
41-
#include "Utils.hpp"
4241

4342
using namespace clp_s::search;
4443
using clp_s::cArchiveFormatDevelopmentVersionFlag;
@@ -47,7 +46,6 @@ using clp_s::cEpochTimeMin;
4746
using clp_s::CommandLineArguments;
4847
using clp_s::KvIrSearchError;
4948
using clp_s::KvIrSearchErrorEnum;
50-
using clp_s::StringUtils;
5149

5250
namespace {
5351
/**

components/core/src/clp_s/search/QueryRunner.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "../../clp/Query.hpp"
1212
#include "../../clp/type_utils.hpp"
1313
#include "../SchemaTree.hpp"
14+
#include "../Utils.hpp"
1415
#include "ast/AndExpr.hpp"
1516
#include "ast/ColumnDescriptor.hpp"
1617
#include "ast/Expression.hpp"

0 commit comments

Comments
 (0)