You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2010/09/22 14:16:40 UTC

svn commit: r999900 - in /subversion/branches/object-model/subversion/bindings/c++: Pool.cpp include/Pool.h

Author: hwright
Date: Wed Sep 22 12:16:40 2010
New Revision: 999900

URL: http://svn.apache.org/viewvc?rev=999900&view=rev
Log:
On the object-model branch:
Most of the pool methods are one-line wrappers around apr equivalents, so
let's just move the definitions to the declaration, to enable better inlining.

* subversion/bindings/c++/include/Pool.h
  (Pool, ~Pool, alloc, registerCleanup, pool, clear): Define in the class
    definition.
 
* subversion/bindings/c++/Pool.cpp
  (Pool, alloc, ~Pool, registerCleanup): Remove.

Modified:
    subversion/branches/object-model/subversion/bindings/c++/Pool.cpp
    subversion/branches/object-model/subversion/bindings/c++/include/Pool.h

Modified: subversion/branches/object-model/subversion/bindings/c++/Pool.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/object-model/subversion/bindings/c%2B%2B/Pool.cpp?rev=999900&r1=999899&r2=999900&view=diff
==============================================================================
--- subversion/branches/object-model/subversion/bindings/c++/Pool.cpp (original)
+++ subversion/branches/object-model/subversion/bindings/c++/Pool.cpp Wed Sep 22 12:16:40 2010
@@ -33,30 +33,9 @@ namespace SVN {
 
 Pool::Pool()
 {
+  // TODO: We may need to protect access to the global pool with a mutex.
   m_pool = svn_pool_create(Private::Core::getCore()->getGlobalPool());
 }
 
-Pool::Pool(Pool &parent)
-{
-  m_pool = svn_pool_create(parent.pool());
-}
-
-void *
-Pool::alloc(apr_size_t sz)
-{
-  return apr_palloc(m_pool, sz);
-}
-
-Pool::~Pool()
-{
-  if (m_pool)
-    svn_pool_destroy(m_pool);
-}
-
-void
-Pool::registerCleanup(apr_status_t (*cleanup_func)(void *), void *baton)
-{
-  apr_pool_cleanup_register(m_pool, baton, cleanup_func, apr_pool_cleanup_null);
-}
 
 }

Modified: subversion/branches/object-model/subversion/bindings/c++/include/Pool.h
URL: http://svn.apache.org/viewvc/subversion/branches/object-model/subversion/bindings/c%2B%2B/include/Pool.h?rev=999900&r1=999899&r2=999900&view=diff
==============================================================================
--- subversion/branches/object-model/subversion/bindings/c++/include/Pool.h (original)
+++ subversion/branches/object-model/subversion/bindings/c++/include/Pool.h Wed Sep 22 12:16:40 2010
@@ -36,6 +36,9 @@ namespace SVN
    * This class manages one APR pool.  Objects of this class may be allocated
    * on the stack, ensuring the pool is destroyed when the function 
    * completes.
+   *
+   * Several methods here are one-liners, and so are defined here as well to
+   * allow better inlining by the compiler.
    */
   class Pool
   {
@@ -57,30 +60,44 @@ namespace SVN
       Pool();
 
       // Explicit to avoid being called as an assignment operator.
-      explicit Pool(Pool &parent);
-      ~Pool();
-
-      void *alloc(apr_size_t sz);
-      void registerCleanup(apr_status_t (*cleanup_func)(void *), void *baton);
-      apr_pool_t *pool() const;
-      void clear() const;
+      inline explicit
+      Pool(Pool &parent)
+      {
+         m_pool = svn_pool_create(parent.pool());
+      }
+
+      inline
+      ~Pool()
+      {
+        svn_pool_destroy(m_pool);
+      }
+
+      inline void *
+      alloc(apr_size_t sz)
+      {
+        return apr_palloc(m_pool, sz);
+      }
+
+      inline void
+      registerCleanup(apr_status_t (*cleanup_func)(void *), void *baton)
+      {
+        apr_pool_cleanup_register(m_pool, baton, cleanup_func,
+                                  apr_pool_cleanup_null);
+      }
+
+      inline apr_pool_t *
+      pool() const
+      {
+        return m_pool;
+      }
+
+      inline void
+      clear() const
+      {
+        svn_pool_clear(m_pool);
+      }
   };
 
-// The following one-line functions are best inlined by the compiler, and
-// need to be implemented in the header file for that to happen.
-
-inline apr_pool_t *
-Pool::pool() const
-{
-  return m_pool;
-}
-
-inline void
-Pool::clear() const
-{
-  svn_pool_clear(m_pool);
-}
-
 }