3 ms·
I double checked and he mentioned a couple other points. One was incrementally hashing the keys to reduce double read. The other was about storing pointers for
by tonymet 3y ago
I double checked and he mentioned a couple other points. One was incrementally hashing the keys to reduce double read. The other was about storing pointers for the value structs more efficiently.
I encourage implementing maps and other DS btw, i was just curious
- canucker2016 3y agoThe authour has already converted the code to using a pointer to value struct for storing in the standard go hash table in Solution 2. Solution 7 contains the code and description for the custom hash table. I can see where interleaving/inlining the hash generation of the station name/key with the search for the separator reduces the number of scans of bytes from 2-3x to just 1x. The second point in Solution 7 was the use of the byte slice to the underlying buffer when the station name is found in the buffer instead of creating a new string. This saves a memory allocation.