Skip to content

Commit

Permalink
Add useful context to comment in hashmap_do_init()
Browse files Browse the repository at this point in the history
  • Loading branch information
craigbarnes committed Jan 21, 2025
1 parent 6f54806 commit 9ca0720
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/util/bsearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ static inline ssize_t bisearch_idx (
}

// This is a wrapper around strcmp(3) with void* parameters, suitable
// for use with bsearch(3) without the need for casting
// for use in bsearch(3) without the need for casting
static inline int vstrcmp(const void *a, const void *b)
{
return strcmp(a, b);
Expand Down
3 changes: 2 additions & 1 deletion src/util/hashmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ static int hashmap_do_init(HashMap *map, size_t size)

// Round up the size to the next power of 2, to allow using simple
// bitwise ops (instead of modulo) to wrap the hash value and also
// to allow quadratic probing with triangular numbers
// to allow quadratic probing with triangular numbers (`i += j++`
// in the `for` loops below)
size = next_pow2(size);
if (unlikely(size == 0)) {
return EOVERFLOW;
Expand Down

0 comments on commit 9ca0720

Please sign in to comment.