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/beinginfo.cpp | |
parent | 042c4f09e34157522692d6f99f5c51bc04e8f27a (diff) | |
download | ManaVerse-4b19b15936faa8e1d5f331cc11147ccfc360bde7.tar.gz ManaVerse-4b19b15936faa8e1d5f331cc11147ccfc360bde7.tar.bz2 ManaVerse-4b19b15936faa8e1d5f331cc11147ccfc360bde7.tar.xz ManaVerse-4b19b15936faa8e1d5f331cc11147ccfc360bde7.zip |
improve a bit code speed.
Diffstat (limited to 'src/resources/beinginfo.cpp')
-rw-r--r-- | src/resources/beinginfo.cpp | 13 |
1 files changed, 10 insertions, 3 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 |