[Xorp-hackers] More ideas for xorp code size improvements.

Ben Greear greearb at candelatech.com
Fri Apr 16 12:10:04 PDT 2010


Maybe callbacks are too much trouble to bother with, but there
are other areas for improvement.  For instance, this patch
(against xorp.ct) saves  around 30KB, and it should help
run-time and stack usage as well.

diff --git a/libxipc/xrl_error.cc b/libxipc/xrl_error.cc
index fd96af1..b6626f1 100644
--- a/libxipc/xrl_error.cc
+++ b/libxipc/xrl_error.cc
@@ -116,3 +116,6 @@ XrlError::error_msg() const
  {
      return _errlet->error_msg();
  }
+
+
+XrlCmdError XrlCmdError::_xce_ok(XrlError::OKAY());
diff --git a/libxipc/xrl_error.hh b/libxipc/xrl_error.hh
index 44dd2fb..4ad2f26 100644
--- a/libxipc/xrl_error.hh
+++ b/libxipc/xrl_error.hh
@@ -179,7 +179,7 @@ public:
       * still return OKAY(), but the return list should indicate the
       * error.
       */
-    static const XrlCmdError OKAY() { return XrlError::OKAY(); }
+    static const XrlCmdError& OKAY() { return _xce_ok; }

      /**
       * Return value when the method arguments are incorrect.
@@ -215,11 +215,12 @@ public:
      /**
       * @return note associated with origin of error (i.e., the reason).
       */
-    string note() const { return _xrl_error.note(); }
+    const string& note() const { return _xrl_error.note(); }

  private:
      XrlCmdError(const XrlError& xe) : _xrl_error(xe) {}
      XrlError _xrl_error;
+    static XrlCmdError _xce_ok;
  };

  ^L
diff --git a/libxipc/xrl_sender.hh b/libxipc/xrl_sender.hh
index 991d40a..123bcec 100644
--- a/libxipc/xrl_sender.hh
+++ b/libxipc/xrl_sender.hh
@@ -30,6 +30,7 @@ class XrlError;

  /**
   * Base for classes able to transport Xrls.
+ * See xrl_router.hh for implementor of this base class.
   */
  class XrlSender {
  public:


-- 
Ben Greear <greearb at candelatech.com>
Candela Technologies Inc  http://www.candelatech.com



More information about the Xorp-hackers mailing list