This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Make advanceTo() faster on Posting Lists
ClosedPublic

Authored by kbobyrev on Sep 7 2018, 10:42 AM.

Details

Summary

If the current element is already beyond advanceTo()'s DocID, just return instead of doing binary search. This simple optimization saves up to 6-7% performance,

Diff Detail

Repository
rL LLVM

Event Timeline

kbobyrev created this revision.Sep 7 2018, 10:42 AM
kbobyrev updated this revision to Diff 164462.Sep 7 2018, 10:45 AM
kbobyrev edited the summary of this revision. (Show Details)
ilya-biryukov accepted this revision.Sep 10 2018, 12:17 AM

LGTM

clang-tools-extra/clangd/index/dex/Iterator.cpp
41 ↗(On Diff #164462)

Maybe add a short comment that this gives performance boost?
Otherwise this looks redundant when reading the code

This revision is now accepted and ready to land.Sep 10 2018, 12:17 AM
kbobyrev updated this revision to Diff 164623.Sep 10 2018, 12:46 AM
kbobyrev marked an inline comment as done.

Add a short comment on why calling lower_bound is redundant. Also, don't spend extra line on return by inverting the condition.

This revision was automatically updated to reflect the committed changes.