On the 1.10-cache-improvement branch:
* subversion/libsvn_subr/cache-membuffer.c
(combine_key): Explain how important reversibility is on this optimized
code path. No functional change.
git-svn-id: https://svn.apache.org/repos/asf/subversion/branches/1.10-cache-improvements@1681965 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/subversion/libsvn_subr/cache-membuffer.c b/subversion/libsvn_subr/cache-membuffer.c
index da32002..f8d894b 100644
--- a/subversion/libsvn_subr/cache-membuffer.c
+++ b/subversion/libsvn_subr/cache-membuffer.c
@@ -2887,15 +2887,18 @@
* to prevent key collisions. So, we limit ourselves to xor and
* permutations.
*
- * As long as we compare the full combined key, the additional
- * fingerprint collisions introduced by a non-reversible scramble
- * would simply reduce the cache effectiveness.
+ * Since the entry key must preserve the full key (prefix and KEY),
+ * the scramble must not introduce KEY collisions.
*/
data[1] = (data[1] << 27) | (data[1] >> 37);
data[1] ^= data[0] & 0xffff;
data[0] ^= data[1] & APR_UINT64_C(0xffffffffffff0000);
- /* combine with this cache's namespace */
+ /* Combine with this cache's prefix. This is reversible because the
+ * prefix is known through to the respective entry_key element. So,
+ * knowing entry_key.prefix_id, we can still reconstruct KEY (and the
+ * prefix key).
+ */
cache->combined_key.entry_key.fingerprint[0]
= data[0] ^ cache->prefix.fingerprint[0];
cache->combined_key.entry_key.fingerprint[1]