Debian Codegraph @

llvm-project/clang-tools-extra/docs/clang-tidy/checks/performance/inefficient-algorithm.rst

raw
1 .. title:: clang-tidy - performance-inefficient-algorithm
2
3 performance-inefficient-algorithm
4 =================================
5
6
7 Warns on inefficient use of STL algorithms on associative containers.
8
9 Associative containers implement some of the algorithms as methods which
10 should be preferred to the algorithms in the algorithm header. The methods
11 can take advantage of the order of the elements.
12
13 .. code-block:: c++
14
15 std::set<int> s;
16 auto it = std::find(s.begin(), s.end(), 43);
17
18 // becomes
19
20 auto it = s.find(43);
21
22 .. code-block:: c++
23
24 std::set<int> s;
25 auto c = std::count(s.begin(), s.end(), 43);
26
27 // becomes
28
29 auto c = s.count(43);