diff options
author | Tor Brede Vekterli <vekterli@vespa.ai> | 2024-01-18 10:21:52 +0000 |
---|---|---|
committer | Tor Brede Vekterli <vekterli@vespa.ai> | 2024-01-18 10:28:21 +0000 |
commit | a8476292a061bf609e24e2731202b634bba46b95 (patch) | |
tree | 75f906e26551d545fd49f24b0c9be9e9c74dcab2 /searchlib/src/tests | |
parent | ada510e89058979aecd66598d1853fd09ee0b42d (diff) |
Use `string_view` for standalone DFA fuzzy match function
This is to allow for matching non-zero terminated strings,
which will be needed if we are to support fuzzy matching of
streaming tokenized terms.
Note that the underlying DFA API already takes in a string_view,
so this is just moving an implicit `strlen` one step higher in the
stack. This will pull the string data into the CPU cache ever so
slightly earlier than before, but this is not expected to matter
in practice since the data will be used immediately after anyway.
Added explicit `string_view` instantiations at the call sites
to make implicit `strlen` more obviously visible than they
currently are with implicit type conversions from `const char*`.
Also adds a utility constructor to hide default underlying DFA
implementation.
Diffstat (limited to 'searchlib/src/tests')
-rw-r--r-- | searchlib/src/tests/attribute/dfa_fuzzy_matcher/dfa_fuzzy_matcher_test.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/searchlib/src/tests/attribute/dfa_fuzzy_matcher/dfa_fuzzy_matcher_test.cpp b/searchlib/src/tests/attribute/dfa_fuzzy_matcher/dfa_fuzzy_matcher_test.cpp index 433ad9e7671..8ba8c62c5ff 100644 --- a/searchlib/src/tests/attribute/dfa_fuzzy_matcher/dfa_fuzzy_matcher_test.cpp +++ b/searchlib/src/tests/attribute/dfa_fuzzy_matcher/dfa_fuzzy_matcher_test.cpp @@ -197,7 +197,7 @@ dfa_fuzzy_match_in_dictionary_no_skip(std::string_view target, const StringEnumS size_t seeks = 0; for (;itr.valid(); ++itr) { auto word = store.get_value(itr.getKey().load_relaxed()); - if (matcher.is_match(word)) { + if (matcher.is_match(std::string_view(word))) { ++matches; if (collect_matches) { matched_words.push_back(word); |