mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
keys: Cache the hash value to avoid lots of recalculation
Cache the hash of the key's type and description in the index key so that we're not recalculating it every time we look at a key during a search. The hash function does a bunch of multiplications, so evading those is probably worthwhile - especially as this is done for every key examined during a search. This also allows the methods used by assoc_array to get chunks of index-key to be simplified. Signed-off-by: David Howells <dhowells@redhat.com>
This commit is contained in:
parent
f771fde820
commit
355ef8e158
4 changed files with 25 additions and 16 deletions
|
@ -86,6 +86,8 @@ struct keyring_list;
|
|||
struct keyring_name;
|
||||
|
||||
struct keyring_index_key {
|
||||
/* [!] If this structure is altered, the union in struct key must change too! */
|
||||
unsigned long hash; /* Hash value */
|
||||
union {
|
||||
struct {
|
||||
#ifdef __LITTLE_ENDIAN /* Put desc_len at the LSB of x */
|
||||
|
@ -213,6 +215,7 @@ struct key {
|
|||
union {
|
||||
struct keyring_index_key index_key;
|
||||
struct {
|
||||
unsigned long hash;
|
||||
unsigned long len_desc;
|
||||
struct key_type *type; /* type of key */
|
||||
char *description;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue