Browse Source

[2565] Avoid redundant construction in parseRRParams()

Mukund Sivaraman 12 years ago
parent
commit
4d6495aa80
1 changed files with 8 additions and 11 deletions
  1. 8 11
      src/lib/dns/master_loader.cc

+ 8 - 11
src/lib/dns/master_loader.cc

@@ -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()));
     }