mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
Specialize block hash copies for the full hash size
This commit is contained in:
parent
b64c28b537
commit
902c19b668
8 changed files with 29 additions and 15 deletions
|
|
@ -692,6 +692,20 @@ int filter_content(tommy_list* contentlist, const char* mount_point, size_t moun
|
|||
*/
|
||||
int filter_snapshot(int enable, const char* sub, const char* name);
|
||||
|
||||
/**
|
||||
* Copy a block hash using the configured hash size.
|
||||
*
|
||||
* Keep the common full-size case explicit so the compiler can inline a fixed
|
||||
* 16-byte copy instead of emitting a call to memcpy() with a runtime size.
|
||||
*/
|
||||
static __always_inline void* hash_copy(void* dst, const void* src)
|
||||
{
|
||||
if (BLOCK_HASH_SIZE == HASH_MAX)
|
||||
return memcpy(dst, src, HASH_MAX);
|
||||
else
|
||||
return memcpy(dst, src, BLOCK_HASH_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the specified hash is invalid.
|
||||
*
|
||||
|
|
@ -707,7 +721,7 @@ static inline int hash_is_invalid(const unsigned char* hash)
|
|||
if (BLOCK_HASH_SIZE != HASH_MAX)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < BLOCK_HASH_SIZE; ++i)
|
||||
for (i = 0; i < HASH_MAX; ++i)
|
||||
if (hash[i] != 0x00)
|
||||
return 0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue