From: Mukund Sivaraman Date: Thu, 4 Oct 2012 19:21:29 +0000 (+0530) Subject: [2268] Remove the RdataSet sorting code X-Git-Tag: trac2402_base~58 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a475756bf185c9e364ed00e245e307789e22fed3;p=thirdparty%2Fkea.git [2268] Remove the RdataSet sorting code It was discussed on Jabber and we decided to defer it. --- diff --git a/src/lib/datasrc/memory/zone_data_updater.cc b/src/lib/datasrc/memory/zone_data_updater.cc index f5a85a41c9..864f66dc02 100644 --- a/src/lib/datasrc/memory/zone_data_updater.cc +++ b/src/lib/datasrc/memory/zone_data_updater.cc @@ -27,53 +27,6 @@ namespace isc { namespace datasrc { namespace memory { -namespace { // unnamed namespace - -// Returns a value-less than, or greater-than zero if 'a' is less-than -// or greater-than 'b'. If they are equal, it returns 0. The comparison -// function is such that often-used types such as A, AAAA, NS, SOA, MX, -// etc. are less than other types. See the code for the ordering. -int -compareTypes(const RdataSet* a, const RdataSet* b) { - // First RRType::A() - if (a->type == RRType::A()) { - return (-1); - } else if (b->type == RRType::A()) { - return (1); - } - - // Then, RRType::AAAA(), etc. - if (a->type == RRType::AAAA()) { - return (-1); - } else if (b->type == RRType::AAAA()) { - return (1); - } - - if (a->type == RRType::NS()) { - return (-1); - } else if (b->type == RRType::NS()) { - return (1); - } - - if (a->type == RRType::SOA()) { - return (-1); - } else if (b->type == RRType::SOA()) { - return (1); - } - - if (a->type == RRType::MX()) { - return (-1); - } else if (b->type == RRType::MX()) { - return (1); - } - - // Everything else comes in front of the rest of the list, so that - // we can insert quickly. - return (-1); -} - -} // end of unnamed namespace - void ZoneDataUpdater::addWildcards(const Name& name) { Name wname(name); @@ -314,24 +267,8 @@ ZoneDataUpdater::addRdataSet(const ConstRRsetPtr rrset, RdataSet* rdataset_new = RdataSet::create(mem_sgmt_, encoder_, rrset, rrsig); - - // Insertion sort the new RdataSet into place in the list. - RdataSet* prev = NULL; - RdataSet* current = rdataset_head; - for (; current != NULL; current = current->getNext()) { - if (compareTypes(rdataset_new, current) < 0) { - break; - } - - prev = current; - } - - rdataset_new->next = current; - if (prev != NULL) { - prev->next = rdataset_new; - } else { - node->setData(rdataset_new); - } + rdataset_new->next = rdataset_head; + node->setData(rdataset_new); // Ok, we just put it in. diff --git a/src/lib/datasrc/tests/memory/memory_client_unittest.cc b/src/lib/datasrc/tests/memory/memory_client_unittest.cc index 80bc73f2f2..c078105b6e 100644 --- a/src/lib/datasrc/tests/memory/memory_client_unittest.cc +++ b/src/lib/datasrc/tests/memory/memory_client_unittest.cc @@ -222,13 +222,13 @@ TEST_F(MemoryClientTest, loadFromIterator) { // RRType::MX() RRset rrset = iterator->getNextRRset(); EXPECT_TRUE(rrset); - EXPECT_EQ(RRType::A(), rrset->getType()); + EXPECT_EQ(RRType::MX(), rrset->getType()); EXPECT_EQ(1, rrset->getRRsigDataCount()); // this RRset is signed // RRType::A() RRset rrset = iterator->getNextRRset(); EXPECT_TRUE(rrset); - EXPECT_EQ(RRType::MX(), rrset->getType()); + EXPECT_EQ(RRType::A(), rrset->getType()); EXPECT_EQ(1, rrset->getRRsigDataCount()); // also signed // There's nothing else in this iterator @@ -364,11 +364,11 @@ TEST_F(MemoryClientTest, loadReloadZone) { set = node->getData(); EXPECT_NE(static_cast(NULL), set); - EXPECT_EQ(RRType::A(), set->type); + EXPECT_EQ(RRType::AAAA(), set->type); set = set->getNext(); EXPECT_NE(static_cast(NULL), set); - EXPECT_EQ(RRType::AAAA(), set->type); + EXPECT_EQ(RRType::A(), set->type); set = set->getNext(); EXPECT_EQ(static_cast(NULL), set); @@ -754,11 +754,11 @@ TEST_F(MemoryClientTest, findZoneData) { set = node->getData(); EXPECT_NE(static_cast(NULL), set); - EXPECT_EQ(RRType::A(), set->type); + EXPECT_EQ(RRType::AAAA(), set->type); set = set->getNext(); EXPECT_NE(static_cast(NULL), set); - EXPECT_EQ(RRType::AAAA(), set->type); + EXPECT_EQ(RRType::A(), set->type); set = set->getNext(); EXPECT_EQ(static_cast(NULL), set);