mu: optimize indexing (get_uid_term)

Some users were report seeing get_uid_term high in the profiles; so
optimize this:

- make mu_util_get_hash a static inline function (used by get_uid_term)
- don't use 'realpath' in get_uid_term, seem that's the main culprit
- some slight faster string handling there too.
This commit is contained in:
djcb
2015-11-17 10:55:56 +02:00
parent dba2e50979
commit fe8b3430c6
4 changed files with 26 additions and 39 deletions

View File

@ -559,25 +559,3 @@ mu_util_read_password (const char *prompt)
}
const char*
mu_util_get_hash (const char* str)
{
unsigned djbhash, bkdrhash, bkdrseed;
unsigned u;
static char hex[18];
g_return_val_if_fail (str, NULL);
djbhash = 5381;
bkdrhash = 0;
bkdrseed = 1313;
for(u = 0; str[u]; ++u) {
djbhash = ((djbhash << 5) + djbhash) + str[u];
bkdrhash = bkdrhash * bkdrseed + str[u];
}
snprintf (hex, sizeof(hex), "%08x%08x", djbhash, bkdrhash);
return hex;
}