You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2015/01/16 17:50:35 UTC

svn commit: r1652457 - in /subversion/trunk/subversion/libsvn_fs_x: util.c util.h

Author: stefan2
Date: Fri Jan 16 16:50:35 2015
New Revision: 1652457

URL: http://svn.apache.org/r1652457
Log:
Most path constructors in FSX are glorified svn_dirent_join_many calls.
If it can be helped, we should not allocate temporary buffers.  This will
allow us to stick with a single pool parameter.  Most callers will use
these functions to create temporary data only and forcing them to pass
in the same scratch pool a second time is pointless.

In this patch, get rid of the temporary buffers for transaction directories
and the standard files in them.

* subversion/libsvn_fs_x/util.c
  (construct_txn_path): New path construction utility.
  (svn_fs_x__path_txn_dir,
   svn_fs_x__path_txn_changes,
   svn_fs_x__path_txn_props,
   svn_fs_x__path_txn_props_final,
   svn_fs_x__path_l2p_proto_index,
   svn_fs_x__path_p2l_proto_index,
   svn_fs_x__path_txn_next_ids,
   svn_fs_x__path_txn_item_index): Simplify by calling the new utility.
                                   The POOL is now a pure RESULT_POOL.

* subversion/libsvn_fs_x/util.h
  (svn_fs_x__path_txn_dir,
   svn_fs_x__path_txn_changes,
   svn_fs_x__path_txn_props,
   svn_fs_x__path_txn_props_final,
   svn_fs_x__path_l2p_proto_index,
   svn_fs_x__path_p2l_proto_index,
   svn_fs_x__path_txn_next_ids,
   svn_fs_x__path_txn_item_index): Sync declarations with the implementations.

Modified:
    subversion/trunk/subversion/libsvn_fs_x/util.c
    subversion/trunk/subversion/libsvn_fs_x/util.h

Modified: subversion/trunk/subversion/libsvn_fs_x/util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/util.c?rev=1652457&r1=1652456&r2=1652457&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/util.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/util.c Fri Jan 16 16:50:35 2015
@@ -271,15 +271,35 @@ svn_fs_x__path_txns_dir(svn_fs_t *fs,
   return svn_dirent_join(fs->path, PATH_TXNS_DIR, result_pool);
 }
 
+/* Return the full path of the file FILENAME within transaction TXN_ID's
+ * transaction directory in FS.  If FILENAME is NULL, return the transaction
+ * directory itself.
+ *
+ * Allocate the result in RESULT_POOL.
+ */
+static const char *
+construct_txn_path(svn_fs_t *fs,
+                   svn_fs_x__txn_id_t txn_id,
+                   const char *filename,
+                   apr_pool_t *result_pool)
+{
+  /* Construct the transaction directory name without temp. allocations. */
+  char buffer[SVN_INT64_BUFFER_SIZE + strlen(PATH_EXT_TXN)];
+  apr_size_t len = svn__ui64tobase36(buffer, txn_id);
+  strncpy(buffer + len, PATH_EXT_TXN, sizeof(buffer) - len - 1);
+
+  /* If FILENAME is NULL, it will terminate the list of segments
+     to concatenate. */
+  return svn_dirent_join_many(result_pool, fs->path, PATH_TXNS_DIR,
+                              buffer, filename, SVN_VA_NULL);
+}
+
 const char *
 svn_fs_x__path_txn_dir(svn_fs_t *fs,
                        svn_fs_x__txn_id_t txn_id,
-                       apr_pool_t *pool)
+                       apr_pool_t *result_pool)
 {
-  return svn_dirent_join_many(pool, svn_fs_x__path_txns_dir(fs, pool),
-                              combine_txn_id_string(txn_id, PATH_EXT_TXN,
-                                                    pool),
-                              SVN_VA_NULL);
+  return construct_txn_path(fs, txn_id, NULL, result_pool);
 }
 
 /* Return the name of the sha1->rep mapping file in transaction TXN_ID
@@ -303,55 +323,51 @@ svn_fs_x__path_txn_sha1(svn_fs_t *fs,
 const char *
 svn_fs_x__path_txn_changes(svn_fs_t *fs,
                            svn_fs_x__txn_id_t txn_id,
-                           apr_pool_t *pool)
+                           apr_pool_t *result_pool)
 {
-  return svn_dirent_join(svn_fs_x__path_txn_dir(fs, txn_id, pool),
-                         PATH_CHANGES, pool);
+  return construct_txn_path(fs, txn_id, PATH_CHANGES, result_pool);
 }
 
 const char *
 svn_fs_x__path_txn_props(svn_fs_t *fs,
                          svn_fs_x__txn_id_t txn_id,
-                         apr_pool_t *pool)
+                         apr_pool_t *result_pool)
 {
-  return svn_dirent_join(svn_fs_x__path_txn_dir(fs, txn_id, pool),
-                         PATH_TXN_PROPS, pool);
+  return construct_txn_path(fs, txn_id, PATH_TXN_PROPS, result_pool);
 }
 
 const char *
 svn_fs_x__path_txn_props_final(svn_fs_t *fs,
                                svn_fs_x__txn_id_t txn_id,
-                               apr_pool_t *pool)
+                               apr_pool_t *result_pool)
 {
-  return svn_dirent_join(svn_fs_x__path_txn_dir(fs, txn_id, pool),
-                         PATH_TXN_PROPS_FINAL, pool);
+  return construct_txn_path(fs, txn_id, PATH_TXN_PROPS_FINAL, result_pool);
 }
 
 const char*
 svn_fs_x__path_l2p_proto_index(svn_fs_t *fs,
                                svn_fs_x__txn_id_t txn_id,
-                               apr_pool_t *pool)
+                               apr_pool_t *result_pool)
 {
-  return svn_dirent_join(svn_fs_x__path_txn_dir(fs, txn_id, pool),
-                         PATH_INDEX PATH_EXT_L2P_INDEX, pool);
+  return construct_txn_path(fs, txn_id, PATH_INDEX PATH_EXT_L2P_INDEX,
+                            result_pool);
 }
 
 const char*
 svn_fs_x__path_p2l_proto_index(svn_fs_t *fs,
                                svn_fs_x__txn_id_t txn_id,
-                               apr_pool_t *pool)
+                               apr_pool_t *result_pool)
 {
-  return svn_dirent_join(svn_fs_x__path_txn_dir(fs, txn_id, pool),
-                         PATH_INDEX PATH_EXT_P2L_INDEX, pool);
+  return construct_txn_path(fs, txn_id, PATH_INDEX PATH_EXT_P2L_INDEX,
+                            result_pool);
 }
 
 const char *
 svn_fs_x__path_txn_next_ids(svn_fs_t *fs,
                             svn_fs_x__txn_id_t txn_id,
-                            apr_pool_t *pool)
+                            apr_pool_t *result_pool)
 {
-  return svn_dirent_join(svn_fs_x__path_txn_dir(fs, txn_id, pool),
-                         PATH_NEXT_IDS, pool);
+  return construct_txn_path(fs, txn_id, PATH_NEXT_IDS, result_pool);
 }
 
 const char *
@@ -371,10 +387,9 @@ svn_fs_x__path_txn_proto_revs(svn_fs_t *
 const char *
 svn_fs_x__path_txn_item_index(svn_fs_t *fs,
                               svn_fs_x__txn_id_t txn_id,
-                              apr_pool_t *pool)
+                              apr_pool_t *result_pool)
 {
-  return svn_dirent_join(svn_fs_x__path_txn_dir(fs, txn_id, pool),
-                         PATH_TXN_ITEM_INDEX, pool);
+  return construct_txn_path(fs, txn_id, PATH_TXN_ITEM_INDEX, result_pool);
 }
 
 const char *

Modified: subversion/trunk/subversion/libsvn_fs_x/util.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/util.h?rev=1652457&r1=1652456&r2=1652457&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/util.h (original)
+++ subversion/trunk/subversion/libsvn_fs_x/util.h Fri Jan 16 16:50:35 2015
@@ -221,12 +221,12 @@ svn_fs_x__txn_by_name(svn_fs_x__txn_id_t
                       const char *txn_name);
 
 /* Return the path of the directory containing the transaction TXN_ID in FS.
- * The result will be allocated in POOL.
+ * The result will be allocated in RESULT_POOL.
  */
 const char *
 svn_fs_x__path_txn_dir(svn_fs_t *fs,
                        svn_fs_x__txn_id_t txn_id,
-                       apr_pool_t *pool);
+                       apr_pool_t *result_pool);
 
 /* Return the path of the 'transactions' directory in FS.
  * The result will be allocated in RESULT_POOL.
@@ -252,57 +252,57 @@ svn_fs_x__path_txn_proto_revs(svn_fs_t *
                               apr_pool_t *result_pool);
 
 /* Return the path of the changes file for transaction TXN_ID in FS.
- * The result will be allocated in POOL.
+ * The result will be allocated in RESULT_POOL.
  */
 const char *
 svn_fs_x__path_txn_changes(svn_fs_t *fs,
                            svn_fs_x__txn_id_t txn_id,
-                           apr_pool_t *pool);
+                           apr_pool_t *result_pool);
 
 /* Return the path of the file containing the log-to-phys index for
  * the transaction identified by TXN_ID in FS.
- * The result will be allocated in POOL.
+ * The result will be allocated in RESULT_POOL.
  */
 const char*
 svn_fs_x__path_l2p_proto_index(svn_fs_t *fs,
                                svn_fs_x__txn_id_t txn_id,
-                               apr_pool_t *pool);
+                               apr_pool_t *result_pool);
 
 /* Return the path of the file containing the phys-to-log index for
  * the transaction identified by TXN_ID in FS.
- * The result will be allocated in POOL.
+ * The result will be allocated in RESULT_POOL.
  */
 const char*
 svn_fs_x__path_p2l_proto_index(svn_fs_t *fs,
                                svn_fs_x__txn_id_t txn_id,
-                               apr_pool_t *pool);
+                               apr_pool_t *result_pool);
 
 /* Return the path of the file containing the transaction properties for
  * the transaction identified by TXN_ID in FS.
- * The result will be allocated in POOL.
+ * The result will be allocated in RESULT_POOL.
  */
 const char *
 svn_fs_x__path_txn_props(svn_fs_t *fs,
                          svn_fs_x__txn_id_t txn_id,
-                         apr_pool_t *pool);
+                         apr_pool_t *result_pool);
 
 /* Return the path of the file containing the "final" transaction
  * properties for the transaction identified by TXN_ID in FS.
- * The result will be allocated in POOL.
+ * The result will be allocated in RESULT_POOL.
  */
 const char *
 svn_fs_x__path_txn_props_final(svn_fs_t *fs,
                                svn_fs_x__txn_id_t txn_id,
-                               apr_pool_t *pool);
+                               apr_pool_t *result_pool);
 
 /* Return the path of the file containing the node and copy ID counters for
  * the transaction identified by TXN_ID in FS.
- * The result will be allocated in POOL.
+ * The result will be allocated in RESULT_POOL.
  */
 const char *
 svn_fs_x__path_txn_next_ids(svn_fs_t *fs,
                             svn_fs_x__txn_id_t txn_id,
-                            apr_pool_t *pool);
+                            apr_pool_t *result_pool);
 
 /* Return the path of the file storing the oldest non-packed revision in FS.
  * The result will be allocated in RESULT_POOL.
@@ -313,12 +313,12 @@ svn_fs_x__path_min_unpacked_rev(svn_fs_t
 
 /* Return the path of the file containing item_index counter for
  * the transaction identified by TXN_ID in FS.
- * The result will be allocated in POOL.
+ * The result will be allocated in RESULT_POOL.
  */
 const char *
 svn_fs_x__path_txn_item_index(svn_fs_t *fs,
                               svn_fs_x__txn_id_t txn_id,
-                              apr_pool_t *pool);
+                              apr_pool_t *result_pool);
 
 /* Return the path of the proto-revision file for transaction TXN_ID in FS.
  * The result will be allocated in POOL.