[clang-tidy] New patterns for performance-inefficient-algorithm check
Open
clang-tidy
enhancement
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
BEFORE:
```c++
auto search(std::set s, int i) {
return std::find_if(s.begin(), s.end(), [&](int val) {
return val > i;
});
}
```
AFTER:
```c++
auto search(std::set s, int i) {
return it->second.upper_bound(i);
}
```
Complexity drops from **O(n)** to **O(log n)**.
Also we can use `lower_bound` for `<=` in this check.
Contributor guide
Assessment
This issue has not been assessed yet.