mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
fdr_compile: don't do string copies in isSuffix
This commit is contained in:
parent
d5b3f2b508
commit
36136f1003
@ -638,16 +638,17 @@ bytecode_ptr<FDR> FDRCompiler::build() {
|
|||||||
|
|
||||||
static
|
static
|
||||||
bool isSuffix(const hwlmLiteral &lit1, const hwlmLiteral &lit2) {
|
bool isSuffix(const hwlmLiteral &lit1, const hwlmLiteral &lit2) {
|
||||||
auto s1 = lit1.s;
|
const auto &s1 = lit1.s;
|
||||||
auto s2 = lit2.s;
|
const auto &s2 = lit2.s;
|
||||||
if (lit1.nocase || lit2.nocase) {
|
|
||||||
upperString(s1);
|
|
||||||
upperString(s2);
|
|
||||||
}
|
|
||||||
size_t len1 = s1.length();
|
size_t len1 = s1.length();
|
||||||
size_t len2 = s2.length();
|
size_t len2 = s2.length();
|
||||||
assert(len1 >= len2);
|
assert(len1 >= len2);
|
||||||
return equal(s2.begin(), s2.end(), s1.begin() + len1 - len2);
|
|
||||||
|
auto lit_cmp = (lit1.nocase || lit2.nocase)
|
||||||
|
? [](char a, char b) { return mytoupper(a) == mytoupper(b); }
|
||||||
|
: [](char a, char b) { return a == b; };
|
||||||
|
|
||||||
|
return equal(s2.begin(), s2.end(), s1.begin() + len1 - len2, lit_cmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user