From 1c2fca88407189fb10e0a49f16e6c11a3eac678a Mon Sep 17 00:00:00 2001 From: Justin Viiret Date: Thu, 14 Jan 2016 10:38:24 +1100 Subject: [PATCH] rose_build_anchored: take ref, not pointer --- src/rose/rose_build_anchored.cpp | 12 ++++-------- src/rose/rose_build_anchored.h | 4 ++-- src/rose/rose_build_bytecode.cpp | 6 +++--- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/rose/rose_build_anchored.cpp b/src/rose/rose_build_anchored.cpp index d7c255fc..96393ba1 100644 --- a/src/rose/rose_build_anchored.cpp +++ b/src/rose/rose_build_anchored.cpp @@ -217,12 +217,8 @@ void populate_holder(const simple_anchored_info &sai, const set &exit_ids, h[v].reports.insert(exit_ids.begin(), exit_ids.end()); } -u32 anchoredStateSize(const anchored_matcher_info *atable) { - if (!atable) { - return 0; - } - - const struct anchored_matcher_info *curr = atable; +u32 anchoredStateSize(const anchored_matcher_info &atable) { + const struct anchored_matcher_info *curr = &atable; // Walk the list until we find the last element; total state size will be // that engine's state offset plus its state requirement. @@ -235,8 +231,8 @@ u32 anchoredStateSize(const anchored_matcher_info *atable) { return curr->state_offset + nfa->scratchStateSize; } -bool anchoredIsMulti(const anchored_matcher_info *atable) { - return atable && atable->next_offset; +bool anchoredIsMulti(const anchored_matcher_info &atable) { + return atable.next_offset; } namespace { diff --git a/src/rose/rose_build_anchored.h b/src/rose/rose_build_anchored.h index a212c84d..d399907b 100644 --- a/src/rose/rose_build_anchored.h +++ b/src/rose/rose_build_anchored.h @@ -50,13 +50,13 @@ struct Grey; aligned_unique_ptr buildAnchoredAutomataMatcher(RoseBuildImpl &build, size_t *asize); -u32 anchoredStateSize(const anchored_matcher_info *atable); +u32 anchoredStateSize(const anchored_matcher_info &atable); /** * \brief True if there is an anchored matcher and it consists of multiple * DFAs. */ -bool anchoredIsMulti(const anchored_matcher_info *atable); +bool anchoredIsMulti(const anchored_matcher_info &atable); #define ANCHORED_FAIL 0 #define ANCHORED_SUCCESS 1 diff --git a/src/rose/rose_build_bytecode.cpp b/src/rose/rose_build_bytecode.cpp index 2fa710f4..45af3bb7 100644 --- a/src/rose/rose_build_bytecode.cpp +++ b/src/rose/rose_build_bytecode.cpp @@ -2245,7 +2245,7 @@ void enforceEngineSizeLimit(const NFA *n, const size_t nfa_size, const Grey &gre static u32 findMinFloatingLiteralMatch(const RoseBuildImpl &build, const anchored_matcher_info *atable) { - if (anchoredIsMulti(atable)) { + if (atable && anchoredIsMulti(*atable)) { DEBUG_PRINTF("multiple anchored dfas\n"); /* We must regard matches from other anchored tables as unordered, as * we do for floating matches. */ @@ -4199,7 +4199,7 @@ aligned_unique_ptr RoseBuildImpl::buildFinalEngine(u32 minWidth) { // Build engine header and copy tables into place. - u32 anchorStateSize = anchoredStateSize(atable.get()); + u32 anchorStateSize = atable ? anchoredStateSize(*atable) : 0; DEBUG_PRINTF("rose history required %zu\n", historyRequired); assert(!cc.streaming || historyRequired <= cc.grey.maxHistoryAvailable); @@ -4372,7 +4372,7 @@ aligned_unique_ptr RoseBuildImpl::buildFinalEngine(u32 minWidth) { write_out(&engine->state_init, (char *)engine.get(), state_scatter, state_scatter_aux_offset); - if (anchoredIsMulti(atable.get())) { + if (atable && anchoredIsMulti(*atable)) { engine->maxSafeAnchoredDROffset = 1; } else { /* overly conservative, really need the min offset of non dr anchored