logoalt Hacker News

illiac786yesterday at 8:16 AM1 replyview on HN

Let’s say, for the positive case, hash comparison is significantly faster.


Replies

pabs3yesterday at 8:38 AM

I feel like that is quite unlikely. Both the hash and bitwise comparisons read both files in both cases. In the not-equal case the hash reads the entirety of both files, so its slower than a start-to-end bitwise comparison, which exits at the first not-equal bit. In the equal case, both read the entirety of both files. Various other bitwise strategies can be faster than start-to-end, rdfind for example checks the start of the file first, then the end, then the rest of the file.

show 1 reply