block: unify roseBlockExec and roseBlockExec_i

This commit is contained in:
Justin Viiret 2016-06-15 09:35:48 +10:00 committed by Matthew Barr
parent 513ac11dbc
commit 66e0b77aa4
2 changed files with 20 additions and 31 deletions

View File

@ -266,13 +266,28 @@ int roseBlockFloating(const struct RoseEngine *t, struct hs_scratch *scratch) {
return can_stop_matching(scratch); return can_stop_matching(scratch);
} }
void roseBlockExec_i(const struct RoseEngine *t, struct hs_scratch *scratch) { void roseBlockExec(const struct RoseEngine *t, struct hs_scratch *scratch) {
assert(t); assert(t);
assert(scratch); assert(scratch);
assert(scratch->core_info.buf); assert(scratch->core_info.buf);
assert(mmbit_sparse_iter_state_size(t->rolesWithStateCount) assert(mmbit_sparse_iter_state_size(t->rolesWithStateCount)
< MAX_SPARSE_ITER_STATES); < MAX_SPARSE_ITER_STATES);
// We should not have been called if we've already been told to terminate
// matching.
assert(!told_to_stop_matching(scratch));
// If this block is shorter than our minimum width, then no pattern in this
// RoseEngine could match.
/* minWidth checks should have already been performed by the caller */
assert(scratch->core_info.len >= t->minWidth);
// Similarly, we may have a maximum width (for engines constructed entirely
// of bi-anchored patterns).
/* This check is now handled by the interpreter */
assert(t->maxBiAnchoredWidth == ROSE_BOUND_INF
|| scratch->core_info.len <= t->maxBiAnchoredWidth);
const size_t length = scratch->core_info.len; const size_t length = scratch->core_info.len;
// We have optimizations for small block scans: we run a single coalesced // We have optimizations for small block scans: we run a single coalesced

View File

@ -29,42 +29,16 @@
#ifndef ROSE_H #ifndef ROSE_H
#define ROSE_H #define ROSE_H
#include "rose_types.h"
#include "rose_internal.h"
#include "runtime.h"
#include "scratch.h"
#include "ue2common.h" #include "ue2common.h"
#include "util/multibit.h"
struct RoseEngine;
struct hs_scratch;
// Initialise state space for engine use. // Initialise state space for engine use.
void roseInitState(const struct RoseEngine *t, char *state); void roseInitState(const struct RoseEngine *t, char *state);
void roseBlockExec_i(const struct RoseEngine *t, struct hs_scratch *scratch);
/* assumes core_info in scratch has been init to point to data */ /* assumes core_info in scratch has been init to point to data */
static really_inline void roseBlockExec(const struct RoseEngine *t, struct hs_scratch *scratch);
void roseBlockExec(const struct RoseEngine *t, struct hs_scratch *scratch) {
assert(t);
assert(scratch);
assert(scratch->core_info.buf);
// We should not have been called if we've already been told to terminate
// matching.
assert(!told_to_stop_matching(scratch));
// If this block is shorter than our minimum width, then no pattern in this
// RoseEngine could match.
/* minWidth checks should have already been performed by the caller */
assert(scratch->core_info.len >= t->minWidth);
// Similarly, we may have a maximum width (for engines constructed entirely
// of bi-anchored patterns).
/* This check is now handled by the interpreter */
assert(t->maxBiAnchoredWidth == ROSE_BOUND_INF
|| scratch->core_info.len <= t->maxBiAnchoredWidth);
roseBlockExec_i(t, scratch);
}
/* assumes core_info in scratch has been init to point to data */ /* assumes core_info in scratch has been init to point to data */
void roseStreamExec(const struct RoseEngine *t, struct hs_scratch *scratch); void roseStreamExec(const struct RoseEngine *t, struct hs_scratch *scratch);