From 5d8297a06a2e966a116d1bcc8bd2ebe7506a178f Mon Sep 17 00:00:00 2001 From: Miod Vallat Date: Thu, 26 Jun 2025 09:50:05 +0200 Subject: [PATCH] Replace pairs of canonCompare calls with a single canonCompare_three_way. Signed-off-by: Miod Vallat --- modules/bindbackend/bindbackend2.hh | 7 +++---- pdns/zonemd.hh | 8 ++------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/modules/bindbackend/bindbackend2.hh b/modules/bindbackend/bindbackend2.hh index cc6658235d..ae32f6115e 100644 --- a/modules/bindbackend/bindbackend2.hh +++ b/modules/bindbackend/bindbackend2.hh @@ -61,10 +61,9 @@ struct Bind2DNSRecord mutable bool auth; bool operator<(const Bind2DNSRecord& rhs) const { - if (qname.canonCompare(rhs.qname)) - return true; - if (rhs.qname.canonCompare(qname)) - return false; + if (int rc = qname.canonCompare_three_way(rhs.qname); rc != 0) { + return rc < 0; + } if (qtype == QType::SOA && rhs.qtype != QType::SOA) return true; return std::tie(qtype, content, ttl) < std::tie(rhs.qtype, rhs.content, rhs.ttl); diff --git a/pdns/zonemd.hh b/pdns/zonemd.hh index 10dc2b6009..7baf83e4d7 100644 --- a/pdns/zonemd.hh +++ b/pdns/zonemd.hh @@ -116,12 +116,8 @@ private: { bool operator()(const RRSetKey_t& lhs, const RRSetKey_t& rhs) const { - // FIXME surely we can be smarter here - if (lhs.first.canonCompare(rhs.first)) { - return true; - } - if (rhs.first.canonCompare(lhs.first)) { - return false; + if (int rc = lhs.first.canonCompare_three_way(rhs.first); rc != 0) { + return rc < 0; } return lhs.second < rhs.second; } -- 2.47.2