I wonder if it's worth saving the memory here and do the dedupe in-place in the original slice, but that may make the code complicated.