]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
mergeCastle: merge common repeats from the castles
authorAlex Coyte <a.coyte@intel.com>
Wed, 2 Aug 2017 03:07:24 +0000 (13:07 +1000)
committerMatthew Barr <matthew.barr@intel.com>
Mon, 21 Aug 2017 01:18:54 +0000 (11:18 +1000)
src/nfa/castlecompile.cpp
src/nfa/castlecompile.h

index b709d3c52ed4225080eea9bc5cb81cc2d0ca1a1a..661c9c2c0d57cc48a9f92ee79b0ce7d9919e3b3a 100644 (file)
@@ -772,7 +772,7 @@ bool mergeCastle(CastleProto &c1, const CastleProto &c2,
         const u32 top = m.first;
         const PureRepeat &pr = m.second;
         DEBUG_PRINTF("top %u\n", top);
-        u32 new_top = c1.add(pr);
+        u32 new_top = c1.merge(pr);
         top_map[top] = new_top;
         DEBUG_PRINTF("adding repeat: map %u->%u\n", top, new_top);
     }
index aa4ed354942adbf4a42a800e4f1aaf741ebe9109..ea5f06dabc7f54b75049367fe477eeee2adb358b 100644 (file)
@@ -128,7 +128,9 @@ buildCastle(const CastleProto &proto,
             const CompileContext &cc, const ReportManager &rm);
 
 /**
- * \brief Merge two CastleProto prototypes together, if possible.
+ * \brief Merge two CastleProto prototypes together, if possible. If a
+ * particular repeat from c2 is already in c1, then it will be reused rather
+ * than adding a duplicate repeat.
  *
  * Returns true if merge of all repeats in c2 into c1 succeeds, and fills
  * mapping with the repeat indices.