aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/hyperscan/src/nfa/vermicelli.h
diff options
context:
space:
mode:
authorIvan Blinkov <ivan@blinkov.ru>2022-02-10 16:47:11 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:11 +0300
commit5b283123c882433dafbaf6b338adeea16c1a0ea0 (patch)
tree339adc63bce23800021202ae4a8328a843dc447a /contrib/libs/hyperscan/src/nfa/vermicelli.h
parent1aeb9a455974457866f78722ad98114bafc84e8a (diff)
downloadydb-5b283123c882433dafbaf6b338adeea16c1a0ea0.tar.gz
Restoring authorship annotation for Ivan Blinkov <ivan@blinkov.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/hyperscan/src/nfa/vermicelli.h')
-rw-r--r--contrib/libs/hyperscan/src/nfa/vermicelli.h150
1 files changed, 75 insertions, 75 deletions
diff --git a/contrib/libs/hyperscan/src/nfa/vermicelli.h b/contrib/libs/hyperscan/src/nfa/vermicelli.h
index 82a241dcf3..ed797d83f9 100644
--- a/contrib/libs/hyperscan/src/nfa/vermicelli.h
+++ b/contrib/libs/hyperscan/src/nfa/vermicelli.h
@@ -87,7 +87,7 @@ const u8 *vermicelliExec(char c, char nocase, const u8 *buf,
}
buf += VERM_BOUNDARY - min;
- assert(buf < buf_end);
+ assert(buf < buf_end);
}
// Aligned loops from here on in
@@ -153,7 +153,7 @@ const u8 *nvermicelliExec(char c, char nocase, const u8 *buf,
}
buf += VERM_BOUNDARY - min;
- assert(buf < buf_end);
+ assert(buf < buf_end);
}
// Aligned loops from here on in
@@ -214,49 +214,49 @@ const u8 *vermicelliDoubleExec(char c1, char c2, char nocase, const u8 *buf,
}
buf += VERM_BOUNDARY - min;
- assert(buf < buf_end);
- }
-
- // Aligned loops from here on in
- const u8 *ptr = nocase ? dvermSearchAlignedNocase(chars1, chars2, c1, c2,
- buf, buf_end)
- : dvermSearchAligned(chars1, chars2, c1, c2, buf,
- buf_end);
- if (ptr) {
- return ptr;
- }
-
- // Tidy up the mess at the end
- ptr = nocase ? dvermPreconditionNocase(chars1, chars2,
- buf_end - VERM_BOUNDARY)
- : dvermPrecondition(chars1, chars2, buf_end - VERM_BOUNDARY);
-
- if (ptr) {
- return ptr;
- }
-
- /* check for partial match at end */
- u8 mask = nocase ? CASE_CLEAR : 0xff;
- if ((buf_end[-1] & mask) == (u8)c1) {
- DEBUG_PRINTF("partial!!!\n");
- return buf_end - 1;
- }
-
- return buf_end;
-}
-
-static really_inline
-const u8 *vermicelliDoubleMaskedExec(char c1, char c2, char m1, char m2,
- const u8 *buf, const u8 *buf_end) {
- DEBUG_PRINTF("double verm scan (\\x%02hhx&\\x%02hhx)(\\x%02hhx&\\x%02hhx) "
- "over %zu bytes\n", c1, m1, c2, m2, (size_t)(buf_end - buf));
- assert(buf < buf_end);
-
- VERM_TYPE chars1 = VERM_SET_FN(c1);
- VERM_TYPE chars2 = VERM_SET_FN(c2);
- VERM_TYPE mask1 = VERM_SET_FN(m1);
- VERM_TYPE mask2 = VERM_SET_FN(m2);
-
+ assert(buf < buf_end);
+ }
+
+ // Aligned loops from here on in
+ const u8 *ptr = nocase ? dvermSearchAlignedNocase(chars1, chars2, c1, c2,
+ buf, buf_end)
+ : dvermSearchAligned(chars1, chars2, c1, c2, buf,
+ buf_end);
+ if (ptr) {
+ return ptr;
+ }
+
+ // Tidy up the mess at the end
+ ptr = nocase ? dvermPreconditionNocase(chars1, chars2,
+ buf_end - VERM_BOUNDARY)
+ : dvermPrecondition(chars1, chars2, buf_end - VERM_BOUNDARY);
+
+ if (ptr) {
+ return ptr;
+ }
+
+ /* check for partial match at end */
+ u8 mask = nocase ? CASE_CLEAR : 0xff;
+ if ((buf_end[-1] & mask) == (u8)c1) {
+ DEBUG_PRINTF("partial!!!\n");
+ return buf_end - 1;
+ }
+
+ return buf_end;
+}
+
+static really_inline
+const u8 *vermicelliDoubleMaskedExec(char c1, char c2, char m1, char m2,
+ const u8 *buf, const u8 *buf_end) {
+ DEBUG_PRINTF("double verm scan (\\x%02hhx&\\x%02hhx)(\\x%02hhx&\\x%02hhx) "
+ "over %zu bytes\n", c1, m1, c2, m2, (size_t)(buf_end - buf));
+ assert(buf < buf_end);
+
+ VERM_TYPE chars1 = VERM_SET_FN(c1);
+ VERM_TYPE chars2 = VERM_SET_FN(c2);
+ VERM_TYPE mask1 = VERM_SET_FN(m1);
+ VERM_TYPE mask2 = VERM_SET_FN(m2);
+
#ifdef HAVE_AVX512
if (buf_end - buf <= VERM_BOUNDARY) {
const u8 *ptr = dvermMiniMasked(chars1, chars2, mask1, mask2, buf,
@@ -277,42 +277,42 @@ const u8 *vermicelliDoubleMaskedExec(char c1, char c2, char m1, char m2,
assert((buf_end - buf) >= VERM_BOUNDARY);
uintptr_t min = (uintptr_t)buf % VERM_BOUNDARY;
- if (min) {
- // Input isn't aligned, so we need to run one iteration with an
- // unaligned load, then skip buf forward to the next aligned address.
- // There's some small overlap here, but we don't mind scanning it twice
- // if we can do it quickly, do we?
- const u8 *p = dvermPreconditionMasked(chars1, chars2, mask1, mask2, buf);
- if (p) {
- return p;
+ if (min) {
+ // Input isn't aligned, so we need to run one iteration with an
+ // unaligned load, then skip buf forward to the next aligned address.
+ // There's some small overlap here, but we don't mind scanning it twice
+ // if we can do it quickly, do we?
+ const u8 *p = dvermPreconditionMasked(chars1, chars2, mask1, mask2, buf);
+ if (p) {
+ return p;
}
-
- buf += VERM_BOUNDARY - min;
- assert(buf < buf_end);
+
+ buf += VERM_BOUNDARY - min;
+ assert(buf < buf_end);
}
// Aligned loops from here on in
- const u8 *ptr = dvermSearchAlignedMasked(chars1, chars2, mask1, mask2, c1,
- c2, m1, m2, buf, buf_end);
- if (ptr) {
- return ptr;
+ const u8 *ptr = dvermSearchAlignedMasked(chars1, chars2, mask1, mask2, c1,
+ c2, m1, m2, buf, buf_end);
+ if (ptr) {
+ return ptr;
+ }
+
+ // Tidy up the mess at the end
+ ptr = dvermPreconditionMasked(chars1, chars2, mask1, mask2,
+ buf_end - VERM_BOUNDARY);
+
+ if (ptr) {
+ return ptr;
}
-
- // Tidy up the mess at the end
- ptr = dvermPreconditionMasked(chars1, chars2, mask1, mask2,
- buf_end - VERM_BOUNDARY);
-
- if (ptr) {
- return ptr;
- }
-
- /* check for partial match at end */
- if ((buf_end[-1] & m1) == (u8)c1) {
+
+ /* check for partial match at end */
+ if ((buf_end[-1] & m1) == (u8)c1) {
DEBUG_PRINTF("partial!!!\n");
- return buf_end - 1;
- }
-
- return buf_end;
+ return buf_end - 1;
+ }
+
+ return buf_end;
}
// Reverse vermicelli scan. Provides exact semantics and returns (buf - 1) if