2 ms·
> diffs use line numbers to indicate where the change is. The optimal solution would be a minor variation on the AVX-optimised memcmp that also counts the numb
by jiggawatts 6y ago
> diffs use line numbers to indicate where the change is.
The optimal solution would be a minor variation on the AVX-optimised memcmp that also counts the number of times it sees the newline character as it is comparing. You still do a single pass through the data, but you get the prefix comparison and the line number in the same go.
For modern CPUs, this is likely optimal.