]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[1894] Use a single LabelSequence object instead of doing costly name splits
authorMukund Sivaraman <muks@isc.org>
Thu, 16 Jan 2014 08:56:49 +0000 (14:26 +0530)
committerMukund Sivaraman <muks@isc.org>
Thu, 16 Jan 2014 08:56:49 +0000 (14:26 +0530)
src/lib/datasrc/memory/zone_finder.cc

index a6c601b9579bb47e4a78b93b0d5485bb96d79ce0..20ec149ac0da5cdce74bdadf2b9037345aaafe9f 100644 (file)
@@ -911,7 +911,7 @@ InMemoryZoneFinder::findNSEC3(const isc::dns::Name& name, bool recursive) {
     uint8_t labels_buf[LabelSequence::MAX_SERIALIZED_LENGTH];
     const LabelSequence origin_ls(zone_data_.getOriginNode()->
                                   getAbsoluteLabels(labels_buf));
-    const LabelSequence name_ls(name);
+    LabelSequence name_ls(name);
 
     if (!zone_data_.isNSEC3Signed()) {
         isc_throw(DataSourceError,
@@ -967,10 +967,9 @@ InMemoryZoneFinder::findNSEC3(const isc::dns::Name& name, bool recursive) {
     // Examine all names from the query name to the origin name, stripping
     // the deepest label one by one, until we find a name that has a matching
     // NSEC3 hash.
-    for (unsigned int labels = qlabels; labels >= olabels; --labels) {
-        const Name& hname = (labels == qlabels ?
-                             name : name.split(qlabels - labels, labels));
-        const std::string hlabel = hash->calculate(hname);
+    for (unsigned int labels = qlabels; labels >= olabels;
+         --labels, name_ls.stripLeft(1)) {
+        const std::string hlabel = hash->calculate(name_ls);
 
         LOG_DEBUG(logger, DBG_TRACE_BASIC, DATASRC_MEMORY_FINDNSEC3_TRYHASH).
             arg(name).arg(labels).arg(hlabel);