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/macro.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/macro.cc')
-rw-r--r-- | crawl-ref/source/macro.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/crawl-ref/source/macro.cc b/crawl-ref/source/macro.cc index 921d5b5746..63b8a91953 100644 --- a/crawl-ref/source/macro.cc +++ b/crawl-ref/source/macro.cc @@ -141,7 +141,7 @@ static std::string get_userfunction(const keyseq &seq) static bool userfunc_referenced(int index, const macromap &mm) { - for (macromap::const_iterator i = mm.begin(); i != mm.end(); i++) + for (macromap::const_iterator i = mm.begin(); i != mm.end(); ++i) { if (userfunc_index(i->second) == index) return (true); @@ -363,7 +363,7 @@ static std::string vtostr(const keyseq &seq) v = &dummy; } - for (keyseq::const_iterator i = v->begin(); i != v->end(); i++) + for (keyseq::const_iterator i = v->begin(); i != v->end(); ++i) { if (*i <= 32 || *i > 127) { @@ -652,7 +652,7 @@ int macro_buf_get() static void write_map(FILE *f, const macromap &mp, const char *key) { - for (macromap::const_iterator i = mp.begin(); i != mp.end(); i++) + for (macromap::const_iterator i = mp.begin(); i != mp.end(); ++i) { // Need this check, since empty values are added into the // macro struct for all used keyboard commands. @@ -1146,7 +1146,7 @@ void remove_key_recorder(key_recorder* recorder) { std::vector<key_recorder*>::iterator i; - for (i = recorders.begin(); i != recorders.end(); i++) + for (i = recorders.begin(); i != recorders.end(); ++i) if (*i == recorder) { recorders.erase(i); |