]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
fdr_confirm_compile: clean up for loops, iterators
authorJustin Viiret <justin.viiret@intel.com>
Tue, 1 Mar 2016 04:56:18 +0000 (15:56 +1100)
committerMatthew Barr <matthew.barr@intel.com>
Fri, 8 Jul 2016 00:49:24 +0000 (10:49 +1000)
src/fdr/fdr_confirm_compile.cpp

index f4ce736689d2d4b591bb6aded4c193b715e4a97a..f65b36b907a8fc1a4b82380fc6c7a968a09e6de6 100644 (file)
@@ -308,14 +308,12 @@ getFDRConfirm(const vector<hwlmLiteral> &lits, bool applyOneCharOpt,
 
     // Walk the map by hash value assigning indexes and laying out the
     // elements (and their associated string confirm material) in memory.
-    for (std::map<u32, vector<LiteralIndex> >::const_iterator
-             i = res2lits.begin(), e = res2lits.end(); i != e; ++i) {
-        const u32 hash = i->first;
-        const vector<LiteralIndex> &vlidx = i->second;
+    for (const auto &m : res2lits) {
+        const u32 hash = m.first;
+        const vector<LiteralIndex> &vlidx = m.second;
         bitsToLitIndex[hash] = verify_u32(ptr - fdrc_base);
-        for (vector<LiteralIndex>::const_iterator i2 = vlidx.begin(),
-             e2 = vlidx.end(); i2 != e2; ++i2) {
-            LiteralIndex litIdx = *i2;
+        for (auto i = vlidx.begin(), e = vlidx.end(); i != e; ++i) {
+            LiteralIndex litIdx = *i;
 
             // Write LitInfo header.
             u8 *oldPtr = ptr;
@@ -334,7 +332,7 @@ getFDRConfirm(const vector<hwlmLiteral> &lits, bool applyOneCharOpt,
             }
 
             ptr = ROUNDUP_PTR(ptr, alignof(LitInfo));
-            if (i2 + 1 == e2) {
+            if (next(i) == e) {
                 finalLI.next = 0x0;
             } else {
                 // our next field represents an adjustment on top of
@@ -377,12 +375,9 @@ u32 setupMultiConfirms(const vector<hwlmLiteral> &lits,
     u32 totalConfirmSize = 0;
     for (BucketIndex b = 0; b < eng.getNumBuckets(); b++) {
         if (!bucketToLits[b].empty()) {
-            vector<vector<hwlmLiteral> > vl(eng.getConfirmTopLevelSplit());
-            for (vector<LiteralIndex>::const_iterator
-                     i = bucketToLits[b].begin(),
-                     e = bucketToLits[b].end();
-                 i != e; ++i) {
-                hwlmLiteral lit = lits[*i]; // copy
+            vector<vector<hwlmLiteral>> vl(eng.getConfirmTopLevelSplit());
+            for (const LiteralIndex &lit_idx : bucketToLits[b]) {
+                hwlmLiteral lit = lits[lit_idx]; // copy
                 // c is last char of this literal
                 u8 c = *(lit.s.rbegin());