]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
simplify oldestts checking, optimise hot path for non-LS users
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Tue, 2 May 2023 12:02:33 +0000 (14:02 +0200)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Tue, 2 May 2023 12:02:33 +0000 (14:02 +0200)
ext/lmdb-safe/lmdb-typed.hh

index c83ed39859dc34deba34b977294f55343c2acb3f..a48c3af01072aad7e580063a21ab6fb732c38b1b 100644 (file)
@@ -676,16 +676,17 @@ public:
           uint64_t ts = LMDBLS::LSgetTimestamp(id.getNoStripHeader<string_view>());
           uint32_t __id = _id.getNoStripHeader<uint32_t>();
 
-          if (ts < oldestts) {
-            oldestts = ts;
-            oldestid = __id;
+          if (onlyOldest) {
+            if (ts < oldestts) {
+              oldestts = ts;
+              oldestid = __id;
+
+              ids.clear();
+              ids.push_back(oldestid);
+            }
+          } else {
+            ids.push_back(__id);
           }
-          ids.push_back(__id);
-        }
-
-        if (onlyOldest && ids.size() > 1) {
-          ids.clear();
-          ids.push_back(oldestid);
         }
 
         rc = cursor.get(out, id, MDB_NEXT);