================
@@ -64,5 +64,32 @@ RefSlab RefSlab::Builder::build() && {
return RefSlab(std::move(Result), std::move(Arena), Entries.size());
}
+void RefSlab::BuilderExpectUnique::insert(const SymbolID &ID, const Ref &S) {
+ Entry E = {ID, S};
+ E.Reference.Location.FileURI = UniqueStrings.save(S.Location.FileURI).data();
+ Entries.emplace_back(std::move(E));
+}
+
+RefSlab RefSlab::BuilderExpectUnique::build() && {
+ std::vector<std::pair<SymbolID, llvm::ArrayRef<Ref>>> Result;
+ // We'll reuse the arena, as it only has unique strings and we need them all.
+ // We need to group refs by symbol and form contiguous arrays on the arena.
+ // Group by SymbolID.
+ std::sort(Entries.begin(), Entries.end());
+ Entries.erase(std::unique(Entries.begin(), Entries.end()), Entries.end());
----------------
JVApen wrote:
We could, I haven't done so as I did not want to assume 100% uniqueness. In
practice, we also have some code that replaces some text while reading the
index. (Replaces the cwd when creating the index with the cwd of the usage) I
don't believe that would introduce duplicates.
I'll test it out and come back to this.
https://github.com/llvm/llvm-project/pull/156185
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits