Post

Make your #AdventOfCode problem twice as fast with this one weird trick ... I was absolutely sure the compiler (clang-18) would do this for me, but alas, it didn't.... Went from ~40ms to ~20ms. Hat tip to @49pctber.bsky.social I peeked at their code and was like "nah, THAT can't be it..."

0 reposts2 likes

That would be an invalid optimization for the compiler to do. It would totally be a valid optimization for the compiler to do if your integer types were unsigned, but you're using a signed `int64_t` and those two functions give different results if passed -1.