# HG changeset patch # User Mike Becker # Date 1660315739 -7200 # Node ID d566bd3e6af845d652af57aeeaf99f564ef75b5e # Parent 3f3a0d19db58dfa17435b6c7ab93a79901c2378f invert if-condition in preparation for the next bugfix diff -r 3f3a0d19db58 -r d566bd3e6af8 src/hash_map.c --- a/src/hash_map.c Fri Aug 12 16:47:11 2022 +0200 +++ b/src/hash_map.c Fri Aug 12 16:48:59 2022 +0200 @@ -86,7 +86,12 @@ elm = elm->next; } - if (elm == NULL || elm->key.hash != hash) { + if (elm != NULL && elm->key.hash == hash) { + // overwrite existing element + elm->data = value; + } else { + // insert new element + struct cx_hash_map_element_s *e = cxMalloc(allocator, sizeof(struct cx_hash_map_element_s)); if (e == NULL) { return -1; @@ -116,9 +121,6 @@ // increase the size map->size++; - } else { - // (elem != NULL && elem->key.hash == hash) - overwrite value of existing element - elm->data = value; } return 0;