summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/state.cc
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2011-07-04 17:59:38 +0200
committerAdam Borowski <kilobyte@angband.pl>2011-07-05 02:21:51 +0200
commit06bb5b5c8199203001e4b3479351adf321299be5 (patch)
treec0bd4f83380fe5f3f408b3b605838e0d056b309b /crawl-ref/source/state.cc
parenteb03baac873c59367d8308b3c0a535b136f99633 (diff)
downloadcrawl-ref-06bb5b5c8199203001e4b3479351adf321299be5.tar.gz
crawl-ref-06bb5b5c8199203001e4b3479351adf321299be5.zip
cppcheck: fix inefficient checking for emptiness.
On some STL structures size() is slow. I did not bother limitting sed, so innocent bystanders got pulled into the machine, but there's no loss.
Diffstat (limited to 'crawl-ref/source/state.cc')
-rw-r--r--crawl-ref/source/state.cc10
1 files changed, 5 insertions, 5 deletions
diff --git a/crawl-ref/source/state.cc b/crawl-ref/source/state.cc
index c8b595024f..45673abb45 100644
--- a/crawl-ref/source/state.cc
+++ b/crawl-ref/source/state.cc
@@ -312,7 +312,7 @@ bool game_state::is_god_acting() const
ASSERT(god_act.depth >= 0);
ASSERT(!(god_act.depth > 0 && god_act.which_god == GOD_NO_GOD));
ASSERT(!(god_act.depth == 0 && god_act.which_god != GOD_NO_GOD));
- ASSERT(!(god_act.depth == 0 && god_act_stack.size() > 0));
+ ASSERT(!(god_act.depth == 0 && !god_act_stack.empty()));
return (god_act.depth > 0);
}
@@ -368,7 +368,7 @@ void game_state::dec_god_acting(god_type which_god)
if (god_act.depth == 0)
{
god_act.reset();
- if (god_act_stack.size() > 0)
+ if (!god_act_stack.empty())
{
god_act = god_act_stack[god_act_stack.size() - 1];
god_act_stack.pop_back();
@@ -382,7 +382,7 @@ void game_state::dec_god_acting(god_type which_god)
void game_state::clear_god_acting()
{
ASSERT(!is_god_acting());
- ASSERT(god_act_stack.size() == 0);
+ ASSERT(god_act_stack.empty());
god_act.reset();
}
@@ -505,7 +505,7 @@ void game_state::dump()
god_name(god_act.which_god).c_str(), god_act.depth);
}
- if (god_act_stack.size() != 0)
+ if (!god_act_stack.empty())
{
fprintf(stderr, "Other gods acting:\n");
for (unsigned int i = 0; i < god_act_stack.size(); i++)
@@ -522,7 +522,7 @@ void game_state::dump()
debug_dump_mon(mon_act, true);
}
- if (mon_act_stack.size() != 0)
+ if (!mon_act_stack.empty())
{
fprintf(stderr, "Others monsters acting:\n");
for (unsigned int i = 0; i < mon_act_stack.size(); i++)