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
..
2019-04-03 06:43:56 +02:00
2019-04-28 07:40:00 +02:00
2019-04-15 06:37:27 +02:00
2019-03-16 09:17:50 +01:00
2019-03-16 09:17:50 +01:00
2019-03-16 09:17:50 +01:00
2019-03-19 06:25:10 +01:00
2019-03-16 09:17:50 +01:00
2019-05-02 07:00:27 +02:00
2019-03-16 09:17:50 +01:00
2019-03-16 09:17:50 +01:00
2019-05-01 13:00:14 +02:00
2019-04-03 06:43:56 +02:00
2019-04-24 13:06:58 +02:00
2019-03-16 09:17:50 +01:00
2019-04-26 12:30:41 +02:00
2019-04-18 20:21:00 +02:00
2019-03-16 09:17:50 +01:00
2019-04-26 12:22:31 +02:00
2019-03-16 09:17:50 +01:00
2019-04-06 07:44:44 +02:00
2019-03-16 09:17:50 +01:00
2019-05-01 16:34:28 +02:00
2019-03-16 09:17:50 +01:00
2019-04-24 15:35:47 +02:00
2019-03-16 09:17:50 +01:00
2019-04-22 17:37:41 +02:00
2019-03-16 09:17:50 +01:00
2019-04-26 11:30:09 +02:00
2019-03-16 09:17:50 +01:00
2019-04-12 06:47:28 +02:00
2019-03-16 09:17:50 +01:00
2019-03-16 09:17:50 +01:00
2019-03-16 09:17:50 +01:00
2019-05-02 11:04:23 +02:00
2019-05-02 11:04:23 +02:00
2019-04-06 06:54:38 +02:00
2019-04-06 06:54:38 +02:00
2019-05-01 16:34:28 +02:00
2019-03-16 09:17:50 +01:00
2019-03-23 08:36:10 +01:00
2019-03-16 09:17:50 +01:00
2019-04-27 17:17:51 +02:00
2019-03-16 09:17:50 +01:00
2019-03-06 20:51:48 +01:00
2019-03-16 09:17:50 +01:00
2019-03-16 09:17:50 +01:00
2019-04-22 18:52:02 +02:00
2019-05-01 11:54:13 +02:00
2019-04-14 15:00:03 +02:00
2019-03-23 15:57:17 +01:00
2019-03-23 08:36:10 +01:00
2019-04-08 18:09:18 +02:00
2019-04-30 20:19:21 +02:00
2019-04-13 20:01:40 +02:00
2019-05-02 11:04:23 +02:00
2019-05-02 11:04:23 +02:00
2019-04-30 20:31:46 +02:00
2019-04-13 15:34:50 +02:00
2019-04-14 15:00:03 +02:00
2019-04-12 09:10:25 +02:00
2019-05-01 16:34:28 +02:00
2019-05-02 11:04:23 +02:00
2019-04-21 06:46:16 +02:00
2019-03-26 07:09:56 +01:00
2019-05-02 11:04:23 +02:00
2019-05-02 11:04:23 +02:00
2019-04-29 15:17:37 +02:00
2019-04-28 07:58:47 +02:00
2019-04-29 11:50:19 +02:00
2019-05-02 11:04:23 +02:00
2019-03-17 13:09:15 +01:00