From c6e43b896374b43c3a005840d27058cbe56d0032 Mon Sep 17 00:00:00 2001 From: Charles Bouillaguet Date: Tue, 5 Jun 2018 07:43:46 +0200 Subject: [PATCH] hash table: use lookup instead of iteration --- cgminer.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/cgminer.c b/cgminer.c index d1aca0f51b..4076e0dc94 100644 --- a/cgminer.c +++ b/cgminer.c @@ -8121,17 +8121,10 @@ struct work *clone_queued_work_bymidstate(struct cgpu_info *cgpu, char *midstate * given que hashtable. Code using this function must be able * to handle NULL as a return which implies there is no matching work. * The calling function must lock access to the que if it is required. */ -struct work *__find_work_byid(struct work *que, uint32_t id) +struct work *__find_work_byid(struct work *queue, uint32_t id) { - struct work *work, *tmp, *ret = NULL; - - HASH_ITER(hh, que, work, tmp) { - if (work->id == id) { - ret = work; - break; - } - } - + struct work *ret = NULL; + HASH_FIND_INT(queue, &id, ret); return ret; }