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 2013/07/24 16:05:43 UTC

svn commit: r1506564 - in /subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs: cached_data.c util.c util.h

Author: stefan2
Date: Wed Jul 24 14:05:42 2013
New Revision: 1506564

URL: http://svn.apache.org/r1506564
Log:
On the fsfs-improvements branch: factor out a function that
will determine the actual offset of an item depending on
whether that item is in a packed or non-packed revision.

* subversion/libsvn_fs_fs/util.h
  (svn_fs_fs__item_offset): declare new private API

* subversion/libsvn_fs_fs/util.c
  (svn_fs_fs__item_offset): implement

* subversion/libsvn_fs_fs/cached_data.c
  (dbg_log_access,
   open_and_seek_revision): use the new API

Modified:
    subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/cached_data.c
    subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/util.c
    subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/util.h

Modified: subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/cached_data.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/cached_data.c?rev=1506564&r1=1506563&r2=1506564&view=diff
==============================================================================
--- subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/cached_data.c (original)
+++ subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/cached_data.c Wed Jul 24 14:05:42 2013
@@ -75,13 +75,8 @@ dbg_log_access(svn_fs_t *fs,
   apr_off_t offset_in_rev = offset;
 
   /* determine rev / pack file offset */
-  if (svn_fs_fs__is_packed_rev(fs, revision))
-    {
-      apr_off_t rev_offset;
-      SVN_ERR(svn_fs_fs__get_packed_offset(&rev_offset, fs, revision,
-                                           scratch_pool));
-      offset += rev_offset;
-    }
+  SVN_ERR(svn_fs_fs__item_offset(&offset, fs, revision, offset,
+                                 scratch_pool));
 
   /* constructing the pack file description */
   if (revision < ffd->min_unpacked_rev)
@@ -174,15 +169,7 @@ open_and_seek_revision(apr_file_t **file
   SVN_ERR(svn_fs_fs__ensure_revision_exists(rev, fs, pool));
 
   SVN_ERR(svn_fs_fs__open_pack_or_rev_file(&rev_file, fs, rev, pool));
-
-  if (svn_fs_fs__is_packed_rev(fs, rev))
-    {
-      apr_off_t rev_offset;
-
-      SVN_ERR(svn_fs_fs__get_packed_offset(&rev_offset, fs, rev, pool));
-      offset += rev_offset;
-    }
-
+  SVN_ERR(svn_fs_fs__item_offset(&offset, fs, rev, offset, pool));
   SVN_ERR(aligned_seek(rev_file, offset, pool));
 
   *file = rev_file;

Modified: subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/util.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/util.c?rev=1506564&r1=1506563&r2=1506564&view=diff
==============================================================================
--- subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/util.c (original)
+++ subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/util.c Wed Jul 24 14:05:42 2013
@@ -27,6 +27,7 @@
 #include "private/svn_string_private.h"
 
 #include "fs_fs.h"
+#include "pack.h"
 #include "util.h"
 
 #include "../libsvn_fs/fs-loader.h"
@@ -617,3 +618,24 @@ svn_fs_fs__open_pack_or_rev_file(apr_fil
 
   return svn_error_trace(err);
 }
+
+svn_error_t *
+svn_fs_fs__item_offset(apr_off_t *absolute_position,
+                       svn_fs_t *fs,
+                       svn_revnum_t rev,
+                       apr_off_t offset,
+                       apr_pool_t *pool)
+{
+  if (svn_fs_fs__is_packed_rev(fs, rev))
+    {
+      apr_off_t rev_offset;
+      SVN_ERR(svn_fs_fs__get_packed_offset(&rev_offset, fs, rev, pool));
+      *absolute_position = rev_offset + offset;
+    }
+  else
+    {
+      *absolute_position = offset;
+    }
+
+  return SVN_NO_ERROR;
+}

Modified: subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/util.h
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/util.h?rev=1506564&r1=1506563&r2=1506564&view=diff
==============================================================================
--- subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/util.h (original)
+++ subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/util.h Wed Jul 24 14:05:42 2013
@@ -354,4 +354,13 @@ svn_fs_fs__open_pack_or_rev_file(apr_fil
                                  svn_revnum_t rev,
                                  apr_pool_t *pool);
 
+/* For OFFSET within REV in FS, return the position in the respective rev
+   or pack file in *ABSOLUTE_POSITION.  Use POOL for allocations. */
+svn_error_t *
+svn_fs_fs__item_offset(apr_off_t *absolute_position,
+                       svn_fs_t *fs,
+                       svn_revnum_t rev,
+                       apr_off_t offset,
+                       apr_pool_t *pool);
+
 #endif
\ No newline at end of file