cppcheck/man
Paul Fultz II 091f4bcf8d Add check for unnecessary search before insertion
This will warn for cases where searching in an associative container happens before insertion, like this:

```cpp
void f1(std::set<unsigned>& s, unsigned x) {
    if (s.find(x) == s.end()) {
        s.insert(x);
    }
}

void f2(std::map<unsigned, unsigned>& m, unsigned x) {
    if (m.find(x) == m.end()) {
        m.emplace(x, 1);
    } else {
        m[x] = 1;
    }
}
```

In the case of the map it could be written as `m[x] = 1` as it will create the key if it doesnt exist, so the extra search is not necessary.

I have this marked as `performance` as it is mostly concerning performance, but there could be a copy-paste error possibly, although I dont think thats common.
2019-05-02 11:04:23 +02:00
..
images Manual: Added a getting started chapter for the GUI 2017-08-12 23:09:13 +02:00
buildman.sh fix a couple of issues in shell scripts found by codacy. 2016-12-25 00:43:47 +01:00
cppcheck-design.docbook Manual: Don't wrap <programlisting> with <para> 2011-07-01 17:13:51 +02:00
cppcheck.1.xml Fix link to cppcheck wiki in man page (#1714) 2019-02-28 20:37:49 +01:00
manual-ja.docbook change version number on manual-ja.docbook (#1658) 2019-02-10 16:57:48 +01:00
manual.docbook Set version to 1.87.99/1.88 dev 2019-02-27 21:30:54 +01:00
manual.md Add check for unnecessary search before insertion 2019-05-02 11:04:23 +02:00
writing-rules-1.docbook man: tabs to spaces, remove trailing spaces and extra empty lines at the end of files 2012-09-29 13:15:08 +02:00
writing-rules-2.docbook Manual: Add internal links 2011-07-02 16:21:58 +02:00
writing-rules-3.docbook Manual: Add internal links 2011-07-02 16:21:58 +02:00