3 ms·
Faster Go code by being mindful of memory
- lioeters 4y agoFun article! Summary: Rewriting a simple solution using a map of bytes, to using a slice of 256 booleans, then to a slice of 32 bytes (256 bits), resulted in 18x faster code and 40% less memory allocation.
- deleted 4y ago[deleted]
- zegl 4y agoThis intrigued me, and I believe that I've found a solution that's slightly faster for this AoC problem. It's achieved by keeping a running tally/counter for the last 14 characters (benchmark in comments). https://gist.github.com/zegl/1ce3064c8049fa1b99c1dd202d785886 https://gist.github.com/zegl/1ce3064c8049fa1b99c1dd202d78588...