]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2565] Avoid redundant construction in parseRRParams()
authorMukund Sivaraman <muks@isc.org>
Mon, 17 Dec 2012 06:46:01 +0000 (12:16 +0530)
committerMukund Sivaraman <muks@isc.org>
Wed, 19 Dec 2012 03:40:02 +0000 (09:10 +0530)
src/lib/dns/master_loader.cc

index 257e841b424e319c8ef0613cd8dc751ac4abf8a4..30b56ed16160feb7800ff4e60d8e25872c840394 100644 (file)
@@ -210,13 +210,15 @@ private:
             // after the RR class below.
         }
 
-        boost::scoped_ptr<RRClass> rrclass;
-        try {
-            rrclass.reset(new RRClass(rrparam_token.getString()));
+        RRClass rrclass(zone_class_);
+        if (rrclass.fromText(rrparam_token.getString())) {
+            if (rrclass != zone_class_) {
+                // It doesn't really matter much what type of exception
+                // we throw, we catch it just below.
+                isc_throw(isc::BadValue, "Class mismatch: " << rrclass <<
+                          "vs. " << zone_class_);
+            }
             rrparam_token = lexer_.getNextToken(MasterToken::STRING);
-        } catch (const InvalidRRClass&) {
-            // If it's not an rrclass here, use the zone's class.
-            rrclass.reset(new RRClass(zone_class_));
         }
 
         // If we couldn't parse TTL earlier in the stream (above), try
@@ -227,11 +229,6 @@ private:
             rrparam_token = lexer_.getNextToken(MasterToken::STRING);
         }
 
-        if (*rrclass != zone_class_) {
-            isc_throw(InternalException, "Class mismatch: " << *rrclass <<
-                      "vs. " << zone_class_);
-        }
-
         // Return the current string token's value as the RRType.
         return (RRType(rrparam_token.getString()));
     }