diff --git a/clang-tools-extra/clangd/index/dex/Iterator.cpp b/clang-tools-extra/clangd/index/dex/Iterator.cpp --- a/clang-tools-extra/clangd/index/dex/Iterator.cpp +++ b/clang-tools-extra/clangd/index/dex/Iterator.cpp @@ -27,10 +27,6 @@ explicit AndIterator(std::vector> AllChildren) : Iterator(Kind::And), Children(std::move(AllChildren)) { assert(!Children.empty() && "AND iterator should have at least one child."); - // Establish invariants. - for (const auto &Child : Children) - ReachedEnd |= Child->reachedEnd(); - sync(); // When children are sorted by the estimateSize(), sync() calls are more // effective. Each sync() starts with the first child and makes sure all // children point to the same element. If any child is "above" the previous @@ -42,6 +38,10 @@ const std::unique_ptr &RHS) { return LHS->estimateSize() < RHS->estimateSize(); }); + // Establish invariants. + for (const auto &Child : Children) + ReachedEnd |= Child->reachedEnd(); + sync(); } bool reachedEnd() const override { return ReachedEnd; }