It was pointed out that ordering is crucial here, so note that. I also looked into using a vector instead, as described in https://llvm.org/docs/ProgrammersManual.html#dss-sortedvectorset. Which this is in theory perfect for, but we have at least 2 places that update the map and both would need to sort/unique each time. Plus this code is pretty bug prone. If there is future refactoring it's one thing to consider.