From 1fb312312cdd01b3cf59950eacc7762f01c41a50 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Thu, 1 Aug 2019 09:28:27 +0100 Subject: Select hash: Simplify insertion at start of non-empty list. This might help Coverity understand what's going on. --- src/select/hash.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/select/hash.c b/src/select/hash.c index 92457d8..4b11702 100644 --- a/src/select/hash.c +++ b/src/select/hash.c @@ -815,24 +815,23 @@ css_error _insert_into_chain(css_selector_hash *ctx, hash_entry *head, search = search->next; } while (search != NULL); - entry->sel = selector; - _chain_bloom_generate(selector, entry->sel_chain_bloom); - -#ifdef PRINT_CHAIN_BLOOM_DETAILS - print_chain_bloom_details(entry->sel_chain_bloom); -#endif - if (prev == NULL) { - hash_entry temp; - entry->next = entry; - temp = *entry; *entry = *head; - *head = temp; + head->next = entry; + + entry = head; } else { entry->next = prev->next; prev->next = entry; } + entry->sel = selector; + _chain_bloom_generate(selector, entry->sel_chain_bloom); + +#ifdef PRINT_CHAIN_BLOOM_DETAILS + print_chain_bloom_details(entry->sel_chain_bloom); +#endif + ctx->hash_size += sizeof(hash_entry); } -- cgit v1.2.3