4 ms·
The 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
by canucker2016 3y ago
The 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.