33/40
Part 7 of 7 · Follow-upsLearn and do
What about very large files?
Never read one whole. Stream it in chunks: 2 MiB of memory instead of 256, as measured above.
And add a cheap stage between the size and the full hash:
all files.
Any two files that differ in that first block are ruled out after a few KiB, instead of the whole file.
In the editor, FILES maps each path to its bytes. Write still_candidates(files, block): group the paths by their size and their first block bytes, and return the groups of two or more, sorted inside and sorted.