Skip to content

Commit 61dea57

Browse files
committed
review fix
1 parent aaac6a0 commit 61dea57

File tree

6 files changed

+20
-14
lines changed

6 files changed

+20
-14
lines changed

components/core/src/clp/DictionaryReader.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ DictionaryReader<DictionaryIdType, EntryType>::get_entry_matching_value(
243243
for (auto const& entry : m_entries) {
244244
if (entry.get_value() == search_string) {
245245
entries.push_back(&entry);
246-
return entries; /* early exit for case sensitive branch */
246+
// early exit for case sensitive branch
247+
return entries;
247248
}
248249
}
249250
} else {

components/core/src/clp/EncodedVariableInterpreter.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ bool EncodedVariableInterpreter::encode_and_search_dictionary(
386386
LogTypeDictionaryEntry::add_float_var(logtype);
387387
sub_query.add_non_dict_var(encoded_var);
388388
} else {
389-
auto entries = var_dict.get_entry_matching_value(var_str, ignore_case);
389+
auto const entries = var_dict.get_entry_matching_value(var_str, ignore_case);
390390

391391
if (entries.empty()) {
392392
// Not in dictionary
@@ -396,18 +396,18 @@ bool EncodedVariableInterpreter::encode_and_search_dictionary(
396396
LogTypeDictionaryEntry::add_dict_var(logtype);
397397

398398
if (entries.size() == 1) {
399-
clp::VariableDictionaryEntry const* entry = entries[0];
400-
auto encoded_var = encode_var_dict_id(entry->get_id());
399+
auto const* entry = entries.at(0);
400+
encoded_var = encode_var_dict_id(entry->get_id());
401401
sub_query.add_dict_var(encoded_var, entry);
402402
return true;
403403
}
404404

405405
std::unordered_set<encoded_variable_t> encoded_vars;
406-
std::unordered_set<clp::VariableDictionaryEntry const*> entries_set(
406+
std::unordered_set<clp::VariableDictionaryEntry const*> const entries_set(
407407
entries.begin(),
408408
entries.end()
409409
);
410-
for (auto entry : entries) {
410+
for (auto const& entry : entries) {
411411
encoded_vars.insert(encode_var_dict_id(entry->get_id()));
412412
}
413413
sub_query.add_imprecise_dict_var(encoded_vars, entries_set);

components/core/src/clp_s/DictionaryReader.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ DictionaryReader<DictionaryIdType, EntryType>::get_entry_matching_value(
166166
for (auto const& entry : m_entries) {
167167
if (entry.get_value() == search_string) {
168168
entries.push_back(&entry);
169-
return entries; /* early exit for case sensitive branch */
169+
// early exit for case sensitive branch
170+
return entries;
170171
}
171172
}
172173
} else {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -932,12 +932,12 @@ void Output::populate_string_queries(std::shared_ptr<Expression> const& expr) {
932932
}
933933
}
934934

935-
auto entries = m_var_dict->get_entry_matching_value(
935+
auto const entries = m_var_dict->get_entry_matching_value(
936936
unescaped_query_string,
937937
m_ignore_case
938938
);
939939

940-
for (auto entry : entries) {
940+
for (auto const& entry : entries) {
941941
matching_vars.insert(entry->get_id());
942942
}
943943
} else if (EncodedVariableInterpreter::

components/core/src/clp_s/search/clp_search/EncodedVariableInterpreter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ bool EncodedVariableInterpreter::encode_and_search_dictionary(
3434
LogTypeDictionaryEntry::add_double_var(logtype);
3535
sub_query.add_non_dict_var(encoded_var);
3636
} else {
37-
auto entries = var_dict.get_entry_matching_value(var_str, ignore_case);
37+
auto const entries = var_dict.get_entry_matching_value(var_str, ignore_case);
3838

3939
if (entries.empty()) {
4040
// Not in dictionary

components/core/tests/test-EncodedVariableInterpreter.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,13 +381,17 @@ TEST_CASE("EncodedVariableInterpreter", "[EncodedVariableInterpreter]") {
381381
char const cVarSegmentIndexPath[] = "var.segindex";
382382
vector<string> var_strs = {"python2.7.3", "Python2.7.3", "PyThOn2.7.3", "PYTHON2.7.3"};
383383
clp::VariableDictionaryWriter var_dict_writer;
384+
384385
var_dict_writer.open(cVarDictPath, cVarSegmentIndexPath, cVariableDictionaryIdMax);
386+
385387
vector<encoded_variable_t> encoded_vars;
386388
vector<clp::variable_dictionary_id_t> var_ids;
387389
clp::LogTypeDictionaryEntry logtype_dict_entry;
388-
for (auto var_str : var_strs) {
390+
string const msg_template = "here is a string with a dictionary var: ";
391+
392+
for (auto const& var_str : var_strs) {
389393
EncodedVariableInterpreter::encode_and_add_to_dictionary(
390-
var_str,
394+
msg_template + var_str,
391395
logtype_dict_entry,
392396
var_dict_writer,
393397
encoded_vars,
@@ -400,9 +404,9 @@ TEST_CASE("EncodedVariableInterpreter", "[EncodedVariableInterpreter]") {
400404
var_dict_reader.open(cVarDictPath, cVarSegmentIndexPath);
401405
var_dict_reader.read_new_entries();
402406

403-
REQUIRE(var_dict_reader.get_entry_matching_value(var_strs[0], true).size()
407+
REQUIRE(var_dict_reader.get_entry_matching_value(var_strs.at(0), true).size()
404408
== var_strs.size());
405-
REQUIRE(var_dict_reader.get_entry_matching_value(var_strs[0], false).size() == 1);
409+
REQUIRE(var_dict_reader.get_entry_matching_value(var_strs.at(0), false).size() == 1);
406410

407411
var_dict_reader.close();
408412

0 commit comments

Comments
 (0)