- return (node->s ? node->s
- : node->d && node->d->hash != node->hash ? node->d
- : hindex_next__(hindex, (node->hash & hindex->mask) + 1));
+ struct hindex_node *head;
+
+ /* If there's a node with the same hash, return it. */
+ if (node->s) {
+ return node->s;
+ }
+
+ /* If there's another node in the same bucket, return it. */
+ head = hindex_head_node(hindex, node->hash);
+ if (head->d) {
+ return head->d;
+ }
+
+ /* Return the first node in the next (or later) bucket. */
+ return hindex_next__(hindex, (node->hash & hindex->mask) + 1);