This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Make stable_partition on include candidates less slow. NFC
AbandonedPublic

Authored by ioeric on Sep 27 2018, 8:34 AM.

Details

Reviewers
sammccall
Summary

stable_partition on objects is slow (due to copies). Do it on pointers
instead.

Event Timeline

ioeric created this revision.Sep 27 2018, 8:34 AM
sammccall added inline comments.Sep 27 2018, 9:36 AM
clangd/CodeComplete.cpp
325

this seems a bit overly complicated. It does seem like a worry that this code is hot enough to optimize, especially compared to *generating* the list.

But I think we can do something simpler...

415

if this is really hot, you might want to reserve(C.RankedIncludeHeaders.size())

422

What about
(Include.Insertion ? InsertableCandidates : IncludeCandidates).push_back(std::move(Include))

where InsertableCandidates is a vector declared above, and then just move it onto the end of the list after the loop?

ioeric updated this revision to Diff 167361.Sep 27 2018, 12:00 PM
ioeric marked 3 inline comments as done.
  • simplify the code.
sammccall accepted this revision.Oct 4 2018, 2:41 AM

The implementation looks fine, but I believe we concluded that seeing huge lists here was basically a bug.
So you may not want to land it, if you prefer to keep things simple. Up to you.

This revision is now accepted and ready to land.Oct 4 2018, 2:41 AM
ioeric abandoned this revision.Dec 17 2018, 8:49 AM