take mask overhang into account for hwlm accel, float min dist

This commit is contained in:
Alex Coyte
2016-07-18 11:33:13 +10:00
committed by Matthew Barr
parent 34289eb3b4
commit d574557200
3 changed files with 57 additions and 8 deletions

View File

@@ -5031,6 +5031,9 @@ void fillMatcherDistances(const RoseBuildImpl &build, RoseEngine *engine) {
u32 max_d = g[v].max_offset;
u32 min_d = g[v].min_offset;
DEBUG_PRINTF("checking %u: elen %zu min/max %u/%u\n", lit_id,
key.elength_including_mask(), min_d, max_d);
if (build.literal_info[lit_id].undelayed_id != lit_id) {
/* this is a delayed match; need to update delay properties */
/* TODO: can delayed literals ever be in another table ? */
@@ -5050,9 +5053,9 @@ void fillMatcherDistances(const RoseBuildImpl &build, RoseEngine *engine) {
switch (key.table) {
case ROSE_FLOATING:
ENSURE_AT_LEAST(&engine->floatingDistance, max_d);
if (min_d >= key.elength()) {
if (min_d >= key.elength_including_mask()) {
LIMIT_TO_AT_MOST(&engine->floatingMinDistance,
min_d - (u32)key.elength());
min_d - (u32)key.elength_including_mask());
} else {
/* overlapped literals from rose + anchored table can
* cause us to underflow due to sloppiness in

View File

@@ -277,6 +277,17 @@ struct rose_literal_id {
u32 distinctiveness;
size_t elength(void) const { return s.length() + delay; }
size_t elength_including_mask(void) const {
size_t mask_len = msk.size();
for (u8 c : msk) {
if (!c) {
mask_len--;
} else {
break;
}
}
return MAX(mask_len, s.length()) + delay;
}
};
static inline