Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace hardlink discovery rpmhash with STL
This was another tricky one due to various things: the behavior here depends on an undocumented rpmhash implementation detail, namely that multiple values per key are preserved in the insertion order. This is not true for unordered_multimap, the order is implementation defined. Also unlike rpmhash, unordered_multimap does not have a method for retrieving the number of keys, so whether hardlinks were discovered needs to be tracked differently. We avoid both of these problems by realizing that the arrays generated in the second step are exactly the same as we calculated in the first round already. So we collect the indexes to the smart pointer vectors in the discovery stage already, utilizing .emplace() to avoid unnecessary instantiation/destruction or extra lookup. With that, we know there are hardlinks in the file set if any key has more than one index associated. A vector obviously keeps its order when pushing back to it, and finally we save a round of data structure copying when we just transfer the relevant ones to the file index keyed hash we use for hardlink lookups elsewhere, and compiler takes care of all the bookkeeping.
- Loading branch information