2 ms·
I don't know Go, but b and found appear to be byte arrays, not strings, which would imply O(1) indexing.
by pbourke 9y ago
I don't know Go, but b and found appear to be byte arrays, not strings, which would imply O(1) indexing.
- vardump 9y agoSingle core version: find := "07123E1F482356C415F684407A3B8723E10B2CBBC0B8FCD6282C49D37C9C1ABC" That's definitely a string. Otherwise (single core) golang code seems to be just a test whether the compiler is smart enough to remove branch in this code: if (b[n]) == (find[found]) { found += 1 } else { found = 0 } I wouldn't be too surprised if golang compiler generates superfluous range checks costing even more performance. At least golang 1.4 seemed to generate a lot of unnecessary checks in code I optimized a few years ago. Hopefully newer versions are better.
- pbourke 9y agoyep, my mistake - was looking at multicore