clang-tidy - performance-inefficient-algorithm — Extra Clang Tools 21.1.8 documentation

# Extra Clang Tools 21.1.8 documentation

## clang-tidy - performance-inefficient-algorithm

# performance-inefficient-algorithm

Warns on inefficient use of STL algorithms on associative containers.

Associative containers implement some of the algorithms as methods which should be preferred to the algorithms in the algorithm header. The methods can take advantage of the order of the elements.

    std::set<int> s;
    auto it = std::find(s.begin(), s.end(), 43);

    // becomes

    auto it = s.find(43);

    std::set<int> s;
    auto c = std::count(s.begin(), s.end(), 43);

    // becomes

    auto c = s.count(43);