FreeBSD/contrib/subversion/subversion/libsvn_fs_x/cached_data.c
/* Walk through all windows in the representation addressed by RS in FS
 * (excluding the delta bases) and put those not already cached into the
 * window caches.  If MAX_OFFSET is not -1, don't read windows that start
 * at or beyond that offset.  As a side effect, return the total sum of all
 * expanded window sizes in *FULLTEXT_LEN.
 * Use SCRATCH_POOL for temporary allocations.
 */
Walk through all windows in the representation addressed by RS in FS
(excluding the delta bases) and put those not already cached into the
window caches.  If MAX_OFFSET is not -1, don't read windows that start
at or beyond that offset.  As a side effect, return the total sum of all
expanded window sizes in *FULLTEXT_LEN.
Use SCRATCH_POOL for temporary allocations.
Walk through all windows in the representation addressed by RS in FS ( excluding the delta bases ) and put those not already cached into the window caches . If MAX_OFFSET is not - 1 don ' t read windows that start at or beyond that offset . As a side effect return the total sum of all expanded window sizes in * FULLTEXT_LEN . Use SCRATCH_POOL for temporary allocations .
static svn_error_t *
cache_windows(svn_filesize_t *fulltext_len,
              svn_fs_t *fs,
              rep_state_t *rs,
              apr_off_t max_offset,
              apr_pool_t *scratch_pool)
{
  apr_pool_t *iterpool = svn_pool_create(scratch_pool);
  *fulltext_len = 0;
  while (rs->current < rs->size)
    {
      svn_boolean_t is_cached = FALSE;
      window_sizes_t *window_sizes;
      svn_pool_clear(iterpool);
      if (max_offset != -1 && rs->start + rs->current >= max_offset)
        {
          svn_pool_destroy(iterpool);
          return SVN_NO_ERROR;
        }
      SVN_ERR(get_cached_window_sizes(&window_sizes, rs, &is_cached,
                                      iterpool));
      if (is_cached)
        {
          *fulltext_len += window_sizes->target_len;
          rs->current += window_sizes->packed_len;
        }
      else
        {
          svn_txdelta_window_t *window;
          apr_off_t start_offset = rs->start + rs->current;
          apr_off_t end_offset;
          apr_off_t block_start;
          SVN_ERR(rs_aligned_seek(rs, &block_start, start_offset, iterpool));
          SVN_ERR(svn_txdelta_read_svndiff_window(&window,
                                                  rs->sfile->rfile->stream,
                                                  rs->ver, iterpool));
          *fulltext_len += window->tview_len;
          SVN_ERR(svn_fs_x__get_file_offset(&end_offset,
                                            rs->sfile->rfile->file,
                                            iterpool));
          rs->current = end_offset - rs->start;
          if (rs->current > rs->size)
            return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
                          _("Reading one svndiff window read beyond "
                                      "the end of the representation"));
          if (!is_cached)
            SVN_ERR(set_cached_window(window, rs, start_offset, iterpool));
        }
      rs->chunk_index++;
    }
  svn_pool_destroy(iterpool);
  return SVN_NO_ERROR;
}
static svn_error_t * cache_windows ( svn_filesize_t * fulltext_len , svn_fs_t * fs , rep_state_t * rs , apr_off_t max_offset , apr_pool_t * scratch_pool ) { apr_pool_t * iterpool = svn_pool_create ( scratch_pool ) ; * fulltext_len = 0 ; while ( rs -> current < rs -> size ) { svn_boolean_t is_cached = FALSE ; window_sizes_t * window_sizes ; svn_pool_clear ( iterpool ) ; if ( max_offset != -1 && rs -> start + rs -> current >= max_offset ) { svn_pool_destroy ( iterpool ) ; return SVN_NO_ERROR ; } SVN_ERR ( get_cached_window_sizes ( & window_sizes , rs , & is_cached , iterpool ) ) ; if ( is_cached ) { * fulltext_len += window_sizes -> target_len ; rs -> current += window_sizes -> packed_len ; } else { svn_txdelta_window_t * window ; apr_off_t start_offset = rs -> start + rs -> current ; apr_off_t end_offset ; apr_off_t block_start ; SVN_ERR ( rs_aligned_seek ( rs , & block_start , start_offset , iterpool ) ) ; SVN_ERR ( svn_txdelta_read_svndiff_window ( & window , rs -> sfile -> rfile -> stream , rs -> ver , iterpool ) ) ; * fulltext_len += window -> tview_len ; SVN_ERR ( svn_fs_x__get_file_offset ( & end_offset , rs -> sfile -> rfile -> file , iterpool ) ) ; rs -> current = end_offset - rs -> start ; if ( rs -> current > rs -> size ) return svn_error_create ( SVN_ERR_FS_CORRUPT , NULL , _ ( " " " " ) ) ; if ( ! is_cached ) SVN_ERR ( set_cached_window ( window , rs , start_offset , iterpool ) ) ; } rs -> chunk_index ++ ; } svn_pool_destroy ( iterpool ) ; return SVN_NO_ERROR ; }
Walk through all windows in the representation addressed by RS in FS
 (excluding the delta bases) and put those not already cached into the
 window caches.
Walk through all windows in the representation addressed by RS in FS ( excluding the delta bases ) and put those not already cached into the window caches .
/* efficiently skip windows that are still being cached instead
       * of fully decoding them */ /* navigate to & read the current window */ /* aggregate expanded window size */ /* determine on-disk window size */ /* if the window has not been cached before, cache it now
           * (if caching is used for them at all) */