Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib: optimize common prefix computation of two hex strings
Comparing each byte before comparing the nibbles is more efficient. A benchmark comparing the old and new implementations with various common prefix lengths shows: ``` Common hex len/old/3 time: [7.5444 ns 7.5807 ns 7.6140 ns] Common hex len/new/3 time: [1.2100 ns 1.2144 ns 1.2192 ns] Common hex len/old/6 time: [11.849 ns 11.879 ns 11.910 ns] Common hex len/new/6 time: [1.9950 ns 2.0046 ns 2.0156 ns] Common hex len/old/32 time: [63.030 ns 63.345 ns 63.718 ns] Common hex len/new/32 time: [6.4647 ns 6.4800 ns 6.4999 ns] ```
- Loading branch information