]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
better key for packetcache
authorKees Monshouwer <mind04@monshouwer.org>
Sat, 8 Nov 2014 13:08:25 +0000 (14:08 +0100)
committermind04 <mind04@monshouwer.org>
Tue, 23 Dec 2014 07:35:38 +0000 (08:35 +0100)
pdns/packetcache.cc

index 5e35fc7ab16b71a29d1753844a26bb028b968f0a..5c7f013d0ae6d18bd31891169e64d1b593bd79f6 100644 (file)
@@ -290,8 +290,16 @@ bool PacketCache::getEntryLocked(const string &qname, const QType& qtype, CacheE
 
 string PacketCache::pcReverse(const string &content)
 {
-  string tmp = string(content.rbegin(), content.rend());
-  return toLower(boost::replace_all_copy(tmp, ".", "\t"))+"\t";
+  typedef vector<pair<unsigned int, unsigned int> > parts_t;
+  parts_t parts;
+  vstringtok(parts,toLower(content), ".");
+  string ret;
+  ret.reserve(content.size()+1);
+  for(parts_t::reverse_iterator i=parts.rbegin(); i!=parts.rend(); ++i) {
+    ret.append(1, (char)(i->second - i->first));
+    ret.append(content.c_str() + i->first, i->second - i->first);
+  }
+  return ret;
 }
 
 map<char,int> PacketCache::getCounts()