logoalt Hacker News

TheDudeMan12/09/20241 replyview on HN

I suggest improving the probing a little. Something like

  idx = (idx + 1) % map->cap;
becomes

  iterCount++;
  idx = (idx + iterCount) % map->cap;

Replies

meisel12/09/2024

It could be improved even more, performance wise. The potentially expensive modulo could be avoided entirely with an if statement. Or, only use powers of 2 for the capacity, and then you can also use bit wise ops