mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-09-30 03:34:25 +03:00
make dverm more precise
This commit is contained in:
@@ -357,5 +357,7 @@ const u8 *run_accel(const union AccelAux *accel, const u8 *c, const u8 *c_end) {
|
||||
rv = MAX(c + accel->generic.offset, rv);
|
||||
rv -= accel->generic.offset;
|
||||
|
||||
DEBUG_PRINTF("advanced %zd\n", rv - c);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@@ -178,11 +178,21 @@ const u8 *vermicelliDoubleExec(char c1, char c2, char nocase, const u8 *buf,
|
||||
}
|
||||
|
||||
// Aligned loops from here on in
|
||||
if (nocase) {
|
||||
return dvermSearchAlignedNocase(chars1, chars2, c1, c2, buf, buf_end);
|
||||
} else {
|
||||
return dvermSearchAligned(chars1, chars2, c1, c2, buf, buf_end);
|
||||
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);
|
||||
/* buf_end - 1 to be conservative in case last byte is a partial match */
|
||||
return ptr ? ptr : buf_end - 1;
|
||||
|
||||
}
|
||||
|
||||
static really_inline
|
||||
@@ -216,8 +226,18 @@ const u8 *vermicelliDoubleMaskedExec(char c1, char c2, char m1, char m2,
|
||||
}
|
||||
|
||||
// Aligned loops from here on in
|
||||
return dvermSearchAlignedMasked(chars1, chars2, mask1, mask2, c1, c2, m1, m2,
|
||||
buf, buf_end);
|
||||
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);
|
||||
/* buf_end - 1 to be conservative in case last byte is a partial match */
|
||||
return ptr ? ptr : buf_end - 1;
|
||||
|
||||
}
|
||||
|
||||
// Reverse vermicelli scan. Provides exact semantics and returns (buf - 1) if
|
||||
|
@@ -147,7 +147,8 @@ const u8 *dvermSearchAligned(m128 chars1, m128 chars2, u8 c1, u8 c2,
|
||||
return buf + pos;
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static really_inline
|
||||
@@ -169,7 +170,8 @@ const u8 *dvermSearchAlignedNocase(m128 chars1, m128 chars2, u8 c1, u8 c2,
|
||||
return buf + pos;
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static really_inline
|
||||
@@ -190,7 +192,8 @@ const u8 *dvermSearchAlignedMasked(m128 chars1, m128 chars2,
|
||||
return buf + pos;
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// returns NULL if not found
|
||||
|
Reference in New Issue
Block a user