FreeBSD/contrib/subversion/subversion/libsvn_subr/cache-membuffer.c
/* Given the SIZE and PRIORITY of a new item, return the cache level
   (L1 or L2) in fragment CACHE that this item shall be inserted into.
   If we can't find nor make enough room for the item, return NULL.
 */
Given the SIZE and PRIORITY of a new item, return the cache level
(L1 or L2) in fragment CACHE that this item shall be inserted into.
If we can't find nor make enough room for the item, return NULL.
Given the SIZE and PRIORITY of a new item return the cache level ( L1 or L2 ) in fragment CACHE that this item shall be inserted into . If we can ' t find nor make enough room for the item return NULL .
static cache_level_t *
select_level(svn_membuffer_t *cache,
             apr_size_t size,
             apr_uint32_t priority)
{
  if (cache->max_entry_size >= size)
    {
      return ensure_data_insertable_l1(cache, size)
           ? &cache->l1
           : NULL;
    }
  else if (   cache->l2.size >= size
           && MAX_ITEM_SIZE >= size
           && priority > SVN_CACHE__MEMBUFFER_DEFAULT_PRIORITY)
    {
      entry_t dummy_entry = { { { 0 } } };
      dummy_entry.priority = priority;
      dummy_entry.size = size;
      return ensure_data_insertable_l2(cache, &dummy_entry)
           ? &cache->l2
           : NULL;
    }
  return NULL;
}
static cache_level_t * select_level ( svn_membuffer_t * cache , apr_size_t size , apr_uint32_t priority ) { if ( cache -> max_entry_size >= size ) { return ensure_data_insertable_l1 ( cache , size ) ? & cache -> l1 : NULL ; } else if ( cache -> l2 . size >= size && MAX_ITEM_SIZE >= size && priority > SVN_CACHE__MEMBUFFER_DEFAULT_PRIORITY ) { entry_t dummy_entry = { { { 0 } } } ; dummy_entry . priority = priority ; dummy_entry . size = size ; return ensure_data_insertable_l2 ( cache , & dummy_entry ) ? & cache -> l2 : NULL ; } return NULL ; }
Given the SIZE and PRIORITY of a new item, return the cache level
(L1 or L2) in fragment CACHE that this item shall be inserted into.
Given the SIZE and PRIORITY of a new item return the cache level ( L1 or L2 ) in fragment CACHE that this item shall be inserted into .
/* Small items go into L1. */ /* Large but important items go into L2. */ /* Don't cache large, unimportant items. */