From 2caf46713fd3373eeb249cf73abd5e20ea335b5f Mon Sep 17 00:00:00 2001 From: bert hubert Date: Sat, 24 Oct 2015 09:56:23 +0200 Subject: [PATCH] massively speed up DNSRecord operator<, also changing its semantics. We don't order in DNSName canonical order now, but perhaps we should. --- pdns/dnsparser.hh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pdns/dnsparser.hh b/pdns/dnsparser.hh index fa6664958..936ca1005 100644 --- a/pdns/dnsparser.hh +++ b/pdns/dnsparser.hh @@ -277,19 +277,19 @@ struct DNSRecord bool operator<(const DNSRecord& rhs) const { + if(tie(d_name, d_type, d_class) < tie(rhs.d_name, rhs.d_type, rhs.d_class)) + return true; + + if(tie(d_name, d_type, d_class) != tie(rhs.d_name, rhs.d_type, rhs.d_class)) + return false; + string lzrp, rzrp; if(d_content) lzrp=toLower(d_content->getZoneRepresentation()); if(rhs.d_content) rzrp=toLower(rhs.d_content->getZoneRepresentation()); - string llabel=toLower(d_name.toString()); - string rlabel=toLower(rhs.d_name.toString()); - - // XXX is anyone expecting a specific canonical ordering? can we use DNSName builtin < ? - return - tie(llabel, d_type, d_class, lzrp) < - tie(rlabel, rhs.d_type, rhs.d_class, rzrp); + return lzrp < rzrp; } bool operator==(const DNSRecord& rhs) const -- 2.49.0