From 578050d086b4c4db408a04c4ec0f6bdf66c3825b Mon Sep 17 00:00:00 2001 From: bert hubert Date: Wed, 9 Dec 2015 13:25:50 +0100 Subject: [PATCH] speedup, use 'tie' for comparisons in recursor packet cache --- pdns/recpacketcache.hh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pdns/recpacketcache.hh b/pdns/recpacketcache.hh index 2cfaff4fc..aa17ff031 100644 --- a/pdns/recpacketcache.hh +++ b/pdns/recpacketcache.hh @@ -15,6 +15,10 @@ using namespace ::boost::multi_index; //! Stores whole packets, ready for lobbing back at the client. Not threadsafe. +/* Note: we store answers as value AND KEY, and with careful work, we make sure that + you can use a query as a key too. But query and answer must compare as identical! + + This precludes doing anything smart with EDNS directly from the packet */ class RecursorPacketCache { public: @@ -62,10 +66,14 @@ inline bool RecursorPacketCache::Entry::operator<(const struct RecursorPacketCac const struct dnsheader* dh=(const struct dnsheader*) d_packet.c_str(), *rhsdh=(const struct dnsheader*)rhs.d_packet.c_str(); - if(boost::make_tuple(dh->opcode, dh->rd, dh->qdcount) < - boost::make_tuple(rhsdh->opcode, rhsdh->rd, rhsdh->qdcount)) + if(std::tie(dh->opcode, dh->rd, dh->qdcount) < + std::tie(rhsdh->opcode, rhsdh->rd, rhsdh->qdcount)) return true; + if(std::tie(dh->opcode, dh->rd, dh->qdcount) > + std::tie(rhsdh->opcode, rhsdh->rd, rhsdh->qdcount)) + return false; + return dnspacketLessThan(d_packet, rhs.d_packet); } -- 2.40.0