Skip to content

Commit b0c070e

Browse files
[clangd] Simplify ternary expressions with std::optional::value_or (NFC) (#111309)
1 parent 7f65377 commit b0c070e

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

clang-tools-extra/clangd/FindSymbols.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ getWorkspaceSymbols(llvm::StringRef Query, int Limit,
111111
*Req.Limit *= 5;
112112
}
113113
TopN<ScoredSymbolInfo, ScoredSymbolGreater> Top(
114-
Req.Limit ? *Req.Limit : std::numeric_limits<size_t>::max());
114+
Req.Limit.value_or(std::numeric_limits<size_t>::max()));
115115
FuzzyMatcher Filter(Req.Query);
116116

117117
Index->fuzzyFind(Req, [HintPath, &Top, &Filter, AnyScope = Req.AnyScope,

clang-tools-extra/clangd/index/MemIndex.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ bool MemIndex::fuzzyFind(
3131
trace::Span Tracer("MemIndex fuzzyFind");
3232

3333
TopN<std::pair<float, const Symbol *>> Top(
34-
Req.Limit ? *Req.Limit : std::numeric_limits<size_t>::max());
34+
Req.Limit.value_or(std::numeric_limits<size_t>::max()));
3535
FuzzyMatcher Filter(Req.Query);
3636
bool More = false;
3737
for (const auto &Pair : Index) {

clang-tools-extra/clangd/index/dex/Dex.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ bool Dex::fuzzyFind(const FuzzyFindRequest &Req,
264264
return LHS.second > RHS.second;
265265
};
266266
TopN<IDAndScore, decltype(Compare)> Top(
267-
Req.Limit ? *Req.Limit : std::numeric_limits<size_t>::max(), Compare);
267+
Req.Limit.value_or(std::numeric_limits<size_t>::max()), Compare);
268268
for (const auto &IDAndScore : IDAndScores) {
269269
const DocID SymbolDocID = IDAndScore.first;
270270
const auto *Sym = Symbols[SymbolDocID];

0 commit comments

Comments
 (0)