FreeBSD/contrib/subversion/subversion/libsvn_subr/cache-membuffer.c
/* Basically calculate a hash value for KEY of length KEY_LEN, combine it
 * with the CACHE->PREFIX and write the result in CACHE->COMBINED_KEY.
 */
Basically calculate a hash value for KEY of length KEY_LEN, combine it
with the CACHE->PREFIX and write the result in CACHE->COMBINED_KEY.
Basically calculate a hash value for KEY of length KEY_LEN combine it with the CACHE - > PREFIX and write the result in CACHE - > COMBINED_KEY .
static void
combine_key(svn_membuffer_cache_t *cache,
            const void *key,
            apr_ssize_t key_len)
{
  if (key_len != APR_HASH_KEY_STRING && key_len <= 16)
    {
      const apr_size_t prefix_len = cache->prefix.entry_key.key_len;
      apr_uint64_t *data = (void *)((char *)cache->combined_key.full_key.data + 
                                    prefix_len);
      assert(prefix_len <= cache->combined_key.full_key.size - 16);
      cache->combined_key.entry_key.key_len = prefix_len + 16;
      data[0] = 0;
      data[1] = 0;
      memcpy(data, key, key_len);
      data[1] = (data[1] << 27) | (data[1] >> 37);
      data[1] ^= data[0] & 0xffff;
      data[0] ^= data[1] & APR_UINT64_C(0xffffffffffff0000);
      cache->combined_key.entry_key.fingerprint[0]
        = data[0] ^ cache->prefix.entry_key.fingerprint[0];
      cache->combined_key.entry_key.fingerprint[1]
        = data[1] ^ cache->prefix.entry_key.fingerprint[1];
    }
  else
    {
      combine_long_key(cache, key, key_len);
    }
}
static void combine_key ( svn_membuffer_cache_t * cache , const void * key , apr_ssize_t key_len ) { if ( key_len != APR_HASH_KEY_STRING && key_len <= 16 ) { const apr_size_t prefix_len = cache -> prefix . entry_key . key_len ; apr_uint64_t * data = ( void * ) ( ( char * ) cache -> combined_key . full_key . data + prefix_len ) ; assert ( prefix_len <= cache -> combined_key . full_key . size - 16 ) ; cache -> combined_key . entry_key . key_len = prefix_len + 16 ; data [ 0 ] = 0 ; data [ 1 ] = 0 ; memcpy ( data , key , key_len ) ; data [ 1 ] = ( data [ 1 ] << 27 ) | ( data [ 1 ] >> 37 ) ; data [ 1 ] ^= data [ 0 ] & 0xffff ; data [ 0 ] ^= data [ 1 ] & APR_UINT64_C ( 0xffffffffffff0000 ) ; cache -> combined_key . entry_key . fingerprint [ 0 ] = data [ 0 ] ^ cache -> prefix . entry_key . fingerprint [ 0 ] ; cache -> combined_key . entry_key . fingerprint [ 1 ] = data [ 1 ] ^ cache -> prefix . entry_key . fingerprint [ 1 ] ; } else { combine_long_key ( cache , key , key_len ) ; } }
Basically calculate a hash value for KEY of length KEY_LEN, combine it
 with the CACHE->PREFIX and write the result in CACHE->COMBINED_KEY.
Basically calculate a hash value for KEY of length KEY_LEN combine it with the CACHE - > PREFIX and write the result in CACHE - > COMBINED_KEY .
/* short, fixed-size keys are the most common case */ /* Copy of *key, padded with 0.
       * We put it just behind the prefix already copied into the COMBINED_KEY.
       * The buffer space has been allocated when the cache was created. */ /* scramble key DATA.  All of this must be reversible to prevent key
       * collisions.  So, we limit ourselves to xor and permutations. */ /* combine with this cache's namespace */ /* longer or variably sized keys */