Skip to content

Commit

Permalink
hmap: change max filling error to smaller value
Browse files Browse the repository at this point in the history
if hmap's open addressing tries up to 80% of hasmap to find a slot,
an error is raised
  • Loading branch information
nil0x42 committed Sep 4, 2020
1 parent ab32158 commit 6324c81
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/hmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void populate_hmap(t_chunk *chunk)
while (get_next_line(&line, chunk))
{
slot = hash(&line) % g_hmap.size;
has_slots = g_hmap.size;
has_slots = (g_hmap.size * 10) / 8;
while (has_slots--)
{
if (!LINE_ISSET(g_hmap.ptr[slot]))
Expand All @@ -67,12 +67,12 @@ void populate_hmap(t_chunk *chunk)
g_hmap.ptr[slot] = line;
#ifdef DEBUG
filled++;
tmp = (int)((double)filled / (double)g_hmap.size * 100.0);
if (tmp > last_percent_filled) {
last_percent_filled = tmp;
DLOG("populate_hmap(): used %ld/%ld slots (%d%%) ...",
filled, g_hmap.size, tmp);
}
/* tmp = (int)((double)filled / (double)g_hmap.size * 100.0); */
/* if (tmp > last_percent_filled) { */
/* last_percent_filled = tmp; */
/* DLOG("populate_hmap(): used %ld/%ld slots (%d%%) ...", */
/* filled, g_hmap.size, tmp); */
/* } */
#endif
break;
}
Expand Down

0 comments on commit 6324c81

Please sign in to comment.