From 192af63cd2d63e06172c1d42ed096af33188fd61 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 27 Nov 2013 21:01:02 +0300 Subject: Improve a bit draw speed in emoteshortcutcontainer. --- src/gui/widgets/emoteshortcutcontainer.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index 5e2666fd8..256c2a666 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -128,13 +128,20 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics) font->drawString(g, key, emoteX + 2, emoteY + 2); } - const unsigned sz = static_cast(mEmoteImg.size()); - for (unsigned i = 0; i < mMaxItems; i++) + unsigned sz = static_cast(mEmoteImg.size()); + if (sz > mMaxItems) + sz = mMaxItems; + for (unsigned i = 0; i < sz; i++) { - if (i < sz && mEmoteImg[i] && mEmoteImg[i]->sprite) + const EmoteSprite *const emoteImg = mEmoteImg[i]; + if (emoteImg) { - mEmoteImg[i]->sprite->draw(g, (i % mGridWidth) * mBoxWidth + 2, - (i / mGridWidth) * mBoxHeight + 10); + const AnimatedSprite *const sprite = emoteImg->sprite; + if (sprite) + { + sprite->draw(g, (i % mGridWidth) * mBoxWidth + 2, + (i / mGridWidth) * mBoxHeight + 10); + } } } -- cgit v1.2.3-70-g09d2