Reduces time spent in findRef by ~66%.
Ran crude measurement clangd --check=clang/lib/Serialization/ASTReader.cpp
Previous time: 52 min
New time: 12 min
This include time for much more than just docHighlight (hover, definition, tweaks,..). So in this case the speedup is at least 77%.
Moreover running docHighlight on each token previously was O(N^2) and is now O(N) in size of main file. Therefore speedup % would be O(N) instead of a constant. In practice for long-tail large files, I have seen 60-80% speedups.
nit: no need for braces
you can directly build the set with canonicaldecls and consume it here