From 0abd36c63a6ffd16e998fe1552f822ca351ef2b2 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 14 Sep 2011 15:36:47 +0300 Subject: Replace some size() calls to empty(). --- src/actorsprite.cpp | 2 +- src/compoundsprite.h | 3 +++ src/gui/serverdialog.cpp | 2 +- src/resources/iteminfo.cpp | 4 ++-- 4 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp index e90536b2d..6155bb7af 100644 --- a/src/actorsprite.cpp +++ b/src/actorsprite.cpp @@ -331,7 +331,7 @@ void ActorSprite::setupSpriteDisplay(const SpriteDisplay &display, } // Ensure that something is shown, if desired - if (size() == 0 && forceDisplay) + if (empty() && forceDisplay) { if (display.image.empty()) { diff --git a/src/compoundsprite.h b/src/compoundsprite.h index 2211cb80c..d1b019057 100644 --- a/src/compoundsprite.h +++ b/src/compoundsprite.h @@ -85,6 +85,9 @@ public: size_t size() const { return std::vector::size(); } + bool empty() const + { return std::vector::empty(); } + void addSprite(Sprite* sprite); void setSprite(int layer, Sprite* sprite); diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index 1b0dd22aa..5a00d4a76 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -367,7 +367,7 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir): loadServers(false); - if (mServers.size() == 0) + if (mServers.empty()) downloadServerList(); } diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp index a5b81081c..5b07724a1 100644 --- a/src/resources/iteminfo.cpp +++ b/src/resources/iteminfo.cpp @@ -139,7 +139,7 @@ const std::string &ItemInfo::getSound(EquipmentSoundEvent event) const if (i == mSounds.end()) return empty; - return i->second.size() > 0 ? i->second[rand() % i->second.size()] : empty; + return (!i->second.empty()) ? i->second[rand() % i->second.size()] : empty; } std::map *ItemInfo::addReplaceSprite(int sprite, int direction) @@ -222,7 +222,7 @@ const std::string ItemInfo::replaceColors(std::string str, } str = replaceAll(str, "%color%", name); - if (name.size() > 0) + if (!name.empty()) name[0] = static_cast(toupper(name[0])); return replaceAll(str, "%Color%", name); -- cgit v1.2.3-70-g09d2