]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
rose_build_anchored: take ref, not pointer
authorJustin Viiret <justin.viiret@intel.com>
Wed, 13 Jan 2016 23:38:24 +0000 (10:38 +1100)
committerMatthew Barr <matthew.barr@intel.com>
Tue, 1 Mar 2016 00:24:17 +0000 (11:24 +1100)
src/rose/rose_build_anchored.cpp
src/rose/rose_build_anchored.h
src/rose/rose_build_bytecode.cpp

index d7c255fc594d8d4dcfc739b776aae5c35890680b..96393ba17744ed3aff5fe01f33f80ccccff17367 100644 (file)
@@ -217,12 +217,8 @@ void populate_holder(const simple_anchored_info &sai, const set<u32> &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 {
index a212c84dcf9ca4380eb0c95cfdbeb6e247fda2b3..d399907b0d7f7db886849312c2cb3312b906390c 100644 (file)
@@ -50,13 +50,13 @@ struct Grey;
 aligned_unique_ptr<anchored_matcher_info>
 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
index 2fa710f404b47a4838d7fb9c4688d909c78d1514..45af3bb73fcb83e2a88dc15a637489fc9d82960a 100644 (file)
@@ -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<RoseEngine> 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<RoseEngine> 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