Browse Source

[2157] simplify return type of getRequestOpCode()

Yoshitaka Aharen 12 years ago
parent
commit
59d2798eeb
2 changed files with 9 additions and 10 deletions
  1. 2 2
      src/bin/auth/statistics.cc.pre
  2. 7 8
      src/bin/auth/statistics.h

+ 2 - 2
src/bin/auth/statistics.cc.pre

@@ -159,7 +159,7 @@ Counters::incRequest(const MessageAttributes& msgattrs) {
     }
 
     // OPCODE
-    const boost::optional<const isc::dns::Opcode&> opcode =
+    const boost::optional<isc::dns::Opcode>& opcode =
         msgattrs.getRequestOpCode();
     // Increment opcode counter only if the opcode exists.
     if (opcode) {
@@ -203,7 +203,7 @@ Counters::incResponse(const MessageAttributes& msgattrs,
         server_msg_counter_.inc(MSG_REQUEST_BADEDNSVER);
     }
 
-    const boost::optional<const isc::dns::Opcode&> opcode =
+    const boost::optional<isc::dns::Opcode>& opcode =
         msgattrs.getRequestOpCode();
     if (opcode && opcode.get() == Opcode::QUERY()) {
         // compound attributes

+ 7 - 8
src/bin/auth/statistics.h

@@ -75,14 +75,13 @@ public:
     {}
 
     /// \brief Return opcode of the request.
-    /// \return opcode of the request wrapped with boost::optional
-    /// \throw isc::InvalidOperation Opcode is not set
-    const boost::optional<const isc::dns::Opcode&> getRequestOpCode() const {
-        if (req_opcode_) {
-            return (req_opcode_.get());
-        } else {
-            return boost::none;
-        }
+    ///
+    /// \return opcode of the request wrapped with boost::optional; it's
+    ///         converted to false if Opcode hasn't been set.
+    ///
+    /// \throw None
+    const boost::optional<isc::dns::Opcode>& getRequestOpCode() const {
+        return (req_opcode_);
     }
 
     /// \brief Set opcode of the request.