Improve dupe-searching performance

Signed-off-by: nixnodes <code@eth.si>