Issue |
146607
|
Summary |
[clang-tidy] Check request: performance-redundant-std-vector
|
Labels |
clang-tidy
|
Assignees |
|
Reporter |
denzor200
|
Need a check that will find cases where `std::vector` is used redundantly for **fixed-size, statically initialized data**. The check will suggest a replacement with `std::array` for better performance and clarity.
BEFORE:
```
bool foo(int val) {
std::vector<int> v = { 1,2, 5, 10, 33 };
return std::range::find(v, val) != v.end();
}
```
AFTER:
```
bool foo(int val) {
std::array<int, 5> v = { 1,2, 5, 10, 33 };
return std::range::find(v, val) != v.end();
}
```
In C++17 mode the check will produce replacement with CTAD usage:
```
bool foo(int val) {
std::array v = { 1,2, 5, 10, 33 };
return std::range::find(v, val) != v.end();
}
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs