nothings / stb

stb single-file public domain libraries for C/C++
https://twitter.com/nothings
Other
26.81k stars 7.72k forks source link

simplify bucket search loops #1396

Open BenFradella opened 2 years ago

BenFradella commented 2 years ago

Do the bucket search loops that start at pos and loop back through the start in a single loop, rather than being broken out into pairs of identical loops.

This does actually fix a bug. Lines 1394,1395 were missing from the second loop, so the temp key was only set if we found a match in the first loop. I kept the contents of the first loop and deleted the second, so the temp key will get set for any position in the bucket now.

rygorous commented 1 year ago

Bug fix is appreciated, will probably not take this exact implementation but thank you!

BenFradella commented 1 year ago

Not sure how I closed the PR. Seems like it was triggered by a force push. That aside, I thought of a better way to do this than what I had before, so I figured I'd make that change and push it, if only for my own sake. Should be easier for the compiler to unroll the loops and whatnot