[svn] commit: r3896 - /branches/trac440/src/lib/datasrc/zonetable.cc
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Dec 20 20:04:51 UTC 2010
Author: vorner
Date: Mon Dec 20 20:04:51 2010
New Revision: 3896
Log:
ZoneTable::find
Modified:
branches/trac440/src/lib/datasrc/zonetable.cc
Modified: branches/trac440/src/lib/datasrc/zonetable.cc
==============================================================================
--- branches/trac440/src/lib/datasrc/zonetable.cc (original)
+++ branches/trac440/src/lib/datasrc/zonetable.cc Mon Dec 20 20:04:51 2010
@@ -101,6 +101,36 @@
return (result::EXIST);
}
}
+
+ ZoneTable::FindResult findZone(const Name& name) const {
+ ZoneNode *node(NULL);
+ result::Result my_result;
+
+ // Translate the return codes
+ switch (zones.find(name, &node)) {
+ case ZoneTree::EXACTMATCH:
+ my_result = result::SUCCESS;
+ break;
+ case ZoneTree::PARTIALMATCH:
+ my_result = result::PARTIALMATCH;
+ break;
+ // We have no data there, so translate the pointer to NULL as well
+ case ZoneTree::NOTFOUND:
+ return (FindResult(result::NOTFOUND, ConstZonePtr()));
+ // Can Not Happen
+ default:
+ isc_throw(AssertError,
+ "RBTree<Zone>::find returned unexpected result");
+ }
+
+ // Can Not Happen (remember, NOTFOUND is handled)
+ if (!node) {
+ isc_throw(AssertError,
+ "RBTree<Zone>::find gave NULL pointer");
+ }
+
+ return (FindResult(my_result, node->getData()));
+ }
};
ZoneTable::ZoneTable() : impl_(new ZoneTableImpl)
@@ -123,18 +153,8 @@
ZoneTable::FindResult
ZoneTable::findZone(const Name& name) const {
- // Inefficient internal loop to find a longest match.
- // This will be replaced with a single call to more intelligent backend.
- for (int i = 0; i < name.getLabelCount(); ++i) {
- Name matchname(name.split(i));
- ZoneTableImpl::ZoneMap::const_iterator found =
- impl_->zones.find(matchname);
- if (found != impl_->zones.end()) {
- return (FindResult(i == 0 ? result::SUCCESS :
- result::PARTIALMATCH, (*found).second));
- }
- }
- return (FindResult(result::NOTFOUND, ConstZonePtr()));
+ return (impl_->findZone(name));
}
+
} // end of namespace datasrc
} // end of namespace isc
More information about the bind10-changes
mailing list