cppcheck/cfg
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
..
avr.cfg Fixed #8078 (cppcheck-cfg.rng outdated) 2017-07-23 12:09:41 +02:00
boost.cfg Add check for unnecessary search before insertion 2019-05-02 11:04:23 +02:00
bsd.cfg bsd.cfg: Add arc4random* functions with tests. (#1344) 2018-08-16 21:37:40 +02:00
cppcheck-cfg.rng Add check for unnecessary search before insertion 2019-05-02 11:04:23 +02:00
cppcheck-lib.cfg std.cfg: Added support for std::swap. 2017-10-11 13:12:00 +02:00
cppunit.cfg Initial support for CppUnit 2019-02-17 20:16:01 +01:00
daca.cfg Correct two recently added macros 2019-04-19 15:43:17 +02:00
embedded_sql.cfg astyle 2017-11-05 17:56:24 +01:00
gnu.cfg gnu.cfg: Added support for tee(). Reference: http://man7.org/linux/man-pages/man2/tee.2.html 2019-04-26 17:55:47 +02:00
googletest.cfg googletest.cfg: added simple macro implementations 2019-02-24 20:52:51 +01:00
gtk.cfg gtk.cfg: Add some g_list_*() function / macro configurations. 2019-04-18 10:49:02 +02:00
libcerror.cfg libcerror.cfg: Add libcerror configuration file. (#1684) 2019-02-22 12:52:07 +01:00
microsoft_sal.cfg microsoft_sal.cfg: Remove redundant define. 2018-07-11 14:03:00 +02:00
motif.cfg motif.cfg: Add configuration for XFree() 2019-04-16 11:22:08 +02:00
opengl.cfg opengl.cfg: Fix size of 64 bit types. 2019-03-12 16:09:08 +01:00
posix.cfg posix.cfg: Added directions for some interfaces. 2019-05-01 19:57:10 +02:00
python.cfg Add more interfaces and attributes 2019-02-18 21:48:41 +01:00
qt.cfg qt.cfg: Add support for QApplication::translate(). 2019-03-20 16:27:15 +01:00
ruby.cfg ruby.cfg: Configure rb_raise() as `noreturn` function. 2019-03-18 10:04:29 +01:00
sdl.cfg Fixed #8078 (cppcheck-cfg.rng outdated) 2017-07-23 12:09:41 +02:00
sfml.cfg Fixed #8078 (cppcheck-cfg.rng outdated) 2017-07-23 12:09:41 +02:00
sqlite3.cfg sqlite3.cfg: Add more allocation and function configurations. 2019-03-28 10:42:11 +01:00
std.cfg Add check for unnecessary search before insertion 2019-05-02 11:04:23 +02:00
tinyxml2.cfg tinyxml2.cfg: Added support for XMLElement::Attribute(). 2019-01-25 20:15:01 +01:00
windows.cfg windows.cfg: Issue a warning in case _close() is called with a negative file descriptor. 2019-04-26 09:26:25 +02:00
wxwidgets.cfg wxwidgets.cfg: Added support for more interfaces. 2019-04-27 18:36:48 +02:00
zlib.cfg zlib.cfg: Fixes, enhancements and adding argument directions. 2019-03-13 15:03:11 +01:00