util/disk_cache: use a helper to compute cache keys
This will allow to hash additional data into the cache keys or even change the hashing algorithm easily, should we decide to do so. v2: don't try to compute key (and crash) if cache is disabled Signed-off-by: Grazvydas Ignotas <notasas@gmail.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
This commit is contained in:

committed by
Timothy Arceri

parent
021c87fa24
commit
529a767041
@@ -1063,4 +1063,11 @@ disk_cache_has_key(struct disk_cache *cache, const cache_key key)
|
||||
return memcmp(entry, key, CACHE_KEY_SIZE) == 0;
|
||||
}
|
||||
|
||||
void
|
||||
disk_cache_compute_key(struct disk_cache *cache, const void *data, size_t size,
|
||||
cache_key key)
|
||||
{
|
||||
_mesa_sha1_compute(data, size, key);
|
||||
}
|
||||
|
||||
#endif /* ENABLE_SHADER_CACHE */
|
||||
|
Reference in New Issue
Block a user