diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-09-20 20:50:50 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-09-20 20:50:50 +0300 |
commit | 4b19b15936faa8e1d5f331cc11147ccfc360bde7 (patch) | |
tree | e601b548c0c55a7e434b30cfff328ca5e3662bee /src/resources | |
parent | 042c4f09e34157522692d6f99f5c51bc04e8f27a (diff) | |
download | mv-4b19b15936faa8e1d5f331cc11147ccfc360bde7.tar.gz mv-4b19b15936faa8e1d5f331cc11147ccfc360bde7.tar.bz2 mv-4b19b15936faa8e1d5f331cc11147ccfc360bde7.tar.xz mv-4b19b15936faa8e1d5f331cc11147ccfc360bde7.zip |
improve a bit code speed.
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/beinginfo.cpp | 13 | ||||
-rw-r--r-- | src/resources/beinginfo.h | 2 | ||||
-rw-r--r-- | src/resources/imagewriter.cpp | 2 | ||||
-rw-r--r-- | src/resources/iteminfo.h | 2 |
4 files changed, 14 insertions, 5 deletions
diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp index 48e8b8493..84d32f623 100644 --- a/src/resources/beinginfo.cpp +++ b/src/resources/beinginfo.cpp @@ -77,7 +77,7 @@ BeingInfo::~BeingInfo() delete_all(mDisplay.sprites); } -void BeingInfo::setDisplay(SpriteDisplay display) +void BeingInfo::setDisplay(const SpriteDisplay &display) { mDisplay = display; } @@ -119,8 +119,15 @@ const SoundInfo &BeingInfo::getSound(const SoundEvent event) const static SoundInfo emptySound("", 0); const SoundEvents::const_iterator i = mSounds.find(event); - return (i == mSounds.end() || !i->second || i->second->empty()) - ? emptySound : i->second->at(rand() % i->second->size()); + + if (i == mSounds.end()) + return emptySound; + + const SoundInfoVect *const vect = i->second; + if (!vect || vect->empty()) + return emptySound; + else + return vect->at(rand() % vect->size()); } const Attack *BeingInfo::getAttack(const int id) const diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h index 7437e464d..d465dfa64 100644 --- a/src/resources/beinginfo.h +++ b/src/resources/beinginfo.h @@ -101,7 +101,7 @@ class BeingInfo final const std::string &getName() const A_WARN_UNUSED { return mName; } - void setDisplay(SpriteDisplay display); + void setDisplay(const SpriteDisplay &display); const SpriteDisplay &getDisplay() const A_WARN_UNUSED { return mDisplay; } diff --git a/src/resources/imagewriter.cpp b/src/resources/imagewriter.cpp index 9bdde319b..1db9f139d 100644 --- a/src/resources/imagewriter.cpp +++ b/src/resources/imagewriter.cpp @@ -84,12 +84,14 @@ bool ImageWriter::writePNG(SDL_Surface *const surface, png_set_packing(png_ptr); png_bytep *const row_pointers = new png_bytep[surface->h]; +/* if (!row_pointers) { logger->log1("Had trouble converting surface to row pointers"); fclose(fp); return false; } +*/ for (int i = 0; i < surface->h; i++) { diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index 01522ef7b..292089dc5 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -124,7 +124,7 @@ class ItemInfo final std::string getParticleEffect() const A_WARN_UNUSED { return mParticle; } - void setDisplay(SpriteDisplay display) + void setDisplay(const SpriteDisplay &display) { mDisplay = display; } const SpriteDisplay &getDisplay() const A_WARN_UNUSED |