Hfs: Check duplicates more quickly

When there are a lot of input paths, the double for loop takes a long time. In our case a few thousand files took over an hour.