Skip to content

Commit a37fe8c

Browse files
committed
better key for packetcache
1 parent 0678b25 commit a37fe8c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

pdns/packetcache.cc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,16 @@ bool PacketCache::getEntryLocked(const string &qname, const QType& qtype, CacheE
290290

291291
string PacketCache::pcReverse(const string &content)
292292
{
293-
string tmp = string(content.rbegin(), content.rend());
294-
return toLower(boost::replace_all_copy(tmp, ".", "\t"))+"\t";
293+
typedef vector<pair<unsigned int, unsigned int> > parts_t;
294+
parts_t parts;
295+
vstringtok(parts,toLower(content), ".");
296+
string ret;
297+
ret.reserve(content.size()+1);
298+
for(parts_t::reverse_iterator i=parts.rbegin(); i!=parts.rend(); ++i) {
299+
ret.append(1, (char)(i->second - i->first));
300+
ret.append(content.c_str() + i->first, i->second - i->first);
301+
}
302+
return ret;
295303
}
296304

297305
map<char,int> PacketCache::getCounts()

0 commit comments

Comments
 (0)