From: Mukund Sivaraman Date: Tue, 4 Feb 2014 04:19:00 +0000 (+0530) Subject: [1894] Avoid doing costly name splits (database backend) X-Git-Tag: bind10-1.2.0beta1-release~51^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f2ce3de4f881befc57c6328ceffb549a1a0c76af;p=thirdparty%2Fkea.git [1894] Avoid doing costly name splits (database backend) --- diff --git a/src/lib/datasrc/database.cc b/src/lib/datasrc/database.cc index 9c85054341..d8f8ae0da9 100644 --- a/src/lib/datasrc/database.cc +++ b/src/lib/datasrc/database.cc @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -1108,12 +1109,14 @@ DatabaseClient::Finder::findNSEC3(const Name& name, bool recursive) { // This will be set to the one covering the query name ConstRRsetPtr covering_proof; + LabelSequence name_ls(name); // We keep stripping the leftmost label until we find something. // In case it is recursive, we'll exit the loop at the first iteration. - for (unsigned labels(qlabels); labels >= olabels; -- labels) { - const string hash(calculator->calculate(labels == qlabels ? name : - name.split(qlabels - labels, - labels))); + for (unsigned int labels = qlabels; labels >= olabels; + --labels, name_ls.stripLeft(1)) + { + const std::string hash = calculator->calculate(name_ls); + // Get the exact match for the name. LOG_DEBUG(logger, DBG_TRACE_BASIC, DATASRC_DATABASE_FINDNSEC3_TRYHASH). arg(name).arg(labels).arg(hash);