[clang] [clang][Lex] Optimize the FileCheckPoints search in Preprocessor (PR #206356)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 28 22:47:02 PDT 2026
================
@@ -1746,16 +1746,13 @@ void Preprocessor::removePPCallbacks() {
const char *Preprocessor::getCheckPoint(FileID FID, const char *Start) const {
if (auto It = CheckPoints.find(FID); It != CheckPoints.end()) {
const SmallVector<const char *> &FileCheckPoints = It->second;
- const char *Last = nullptr;
- // FIXME: Do better than a linear search.
- for (const char *P : FileCheckPoints) {
- if (P > Start)
- break;
- Last = P;
+ auto P =
+ std::upper_bound(FileCheckPoints.begin(), FileCheckPoints.end(), Start);
----------------
tbaederr wrote:
```suggestion
llvm::upper_bound(FileCheckPoints, Start);
```
https://github.com/llvm/llvm-project/pull/206356
More information about the cfe-commits
mailing list