brintos

brintos / llvm-project-archived public Read only

0
0
Text · 651 B · 062c62c Raw
30 lines · plain
1.. title:: clang-tidy - performance-inefficient-algorithm2 3performance-inefficient-algorithm4=================================5 6 7Warns on inefficient use of STL algorithms on associative containers.8 9Associative containers implement some of the algorithms as methods which10should be preferred to the algorithms in the algorithm header. The methods11can 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  // becomes19 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  // becomes28 29  auto c = s.count(43);30