g10: Optimize key iteration.

* g10/getkey.c (get_best_pubkey_byname): Use the node returned by
'getkey_next' instead of doing another lookup.

Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
Justus Winter 2016-11-15 15:33:09 +01:00
parent d20107f6da
commit 12834e84ac
1 changed files with 2 additions and 2 deletions

View File

@ -1593,9 +1593,9 @@ get_best_pubkey_byname (ctrl_t ctrl, GETKEY_CTX *retctx, PKT_public_key *pk,
{
/* Rank results and return only the most relevant key. */
struct pubkey_cmp_cookie best = { 0 }, new;
while (getkey_next (ctx, &new.key, NULL) == 0)
KBNODE new_keyblock;
while (getkey_next (ctx, &new.key, &new_keyblock) == 0)
{
KBNODE new_keyblock = get_pubkeyblock (pk_keyid (&new.key));
int diff = pubkey_cmp (ctrl, name, &best, &new, new_keyblock);
release_kbnode (new_keyblock);
if (diff < 0)