diff options
author | Adam Borowski <kilobyte@angband.pl> | 2011-07-04 23:54:32 +0200 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2011-07-05 02:23:41 +0200 |
commit | e4066ccd619b59a64c6fc9643a478fa7ef72f600 (patch) | |
tree | 949c30d9c926395a397e70f0a5ffcedb6edff9ac /crawl-ref/source/store.cc | |
parent | 06bb5b5c8199203001e4b3479351adf321299be5 (diff) | |
download | crawl-ref-e4066ccd619b59a64c6fc9643a478fa7ef72f600.tar.gz crawl-ref-e4066ccd619b59a64c6fc9643a478fa7ef72f600.zip |
cppcheck: use ++p not p++ for complex types (like iterators).
Pre-increment looks worse than post-increment, but on a C++ object the
latter forces an allocation plus copy that is completely unnecessary but the
compiler doesn't know that yet.
Note that I did change some of our iterators to return void rather than the old
or new value for exactly this performance reason before, breaking the expected
behaviour. If that's an issue, tell me, we can use preincrements instead which
have very little penalty.
Diffstat (limited to 'crawl-ref/source/store.cc')
-rw-r--r-- | crawl-ref/source/store.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/crawl-ref/source/store.cc b/crawl-ref/source/store.cc index e0da12fc09..72343b6b20 100644 --- a/crawl-ref/source/store.cc +++ b/crawl-ref/source/store.cc @@ -1300,7 +1300,7 @@ void CrawlHashTable::write(writer &th) const CrawlHashTable::hash_map_type::const_iterator i = hash_map->begin(); - for (; i != hash_map->end(); i++) + for (; i != hash_map->end(); ++i) { marshallString(th, i->first); i->second.write(th); @@ -1358,7 +1358,7 @@ void CrawlHashTable::assert_validity() const unsigned long actual_size = 0; - for (; i != hash_map->end(); i++) + for (; i != hash_map->end(); ++i) { actual_size++; |