summaryrefslogtreecommitdiff
path: root/src/guichan/focushandler.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-08-17 16:34:36 +0300
committerAndrei Karas <akaras@inbox.ru>2012-08-17 16:34:36 +0300
commitc6c4eef4e49bb4de90845408af9f642a1a4e224b (patch)
tree81d192e85b3c075cb2e52671bea4c3c0499dc3f2 /src/guichan/focushandler.cpp
parent093e392dd84c920d26bca17d48ac6611393d087c (diff)
downloadmv-c6c4eef4e49bb4de90845408af9f642a1a4e224b.tar.gz
mv-c6c4eef4e49bb4de90845408af9f642a1a4e224b.tar.bz2
mv-c6c4eef4e49bb4de90845408af9f642a1a4e224b.tar.xz
mv-c6c4eef4e49bb4de90845408af9f642a1a4e224b.zip
Improve size calculations.
Diffstat (limited to 'src/guichan/focushandler.cpp')
-rw-r--r--src/guichan/focushandler.cpp30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/guichan/focushandler.cpp b/src/guichan/focushandler.cpp
index 494a2a899..3a5424851 100644
--- a/src/guichan/focushandler.cpp
+++ b/src/guichan/focushandler.cpp
@@ -74,7 +74,7 @@ namespace gcn
return;
int toBeFocusedIndex = -1;
- for (unsigned int i = 0; i < mWidgets.size(); ++i)
+ for (unsigned int i = 0, sz = mWidgets.size(); i < sz; ++i)
{
if (mWidgets[i] == widget)
{
@@ -157,7 +157,8 @@ namespace gcn
{
int i;
int focusedWidget = -1;
- for (i = 0; i < static_cast<int>(mWidgets.size()); ++i)
+ const int sz = static_cast<int>(mWidgets.size());
+ for (i = 0; i < sz; ++i)
{
if (mWidgets[i] == mFocusedWidget)
focusedWidget = i;
@@ -166,7 +167,7 @@ namespace gcn
// i is a counter that ensures that the following loop
// won't get stuck in an infinite loop
- i = static_cast<int>(mWidgets.size());
+ i = sz;
do
{
++ focusedWidget;
@@ -179,7 +180,7 @@ namespace gcn
-- i;
- if (focusedWidget >= static_cast<int>(mWidgets.size()))
+ if (focusedWidget >= sz)
focusedWidget = 0;
if (focusedWidget == focused)
@@ -212,7 +213,8 @@ namespace gcn
int i;
int focusedWidget = -1;
- for (i = 0; i < static_cast<int>(mWidgets.size()); ++ i)
+ const int sz = static_cast<int>(mWidgets.size());
+ for (i = 0; i < sz; ++ i)
{
if (mWidgets[i] == mFocusedWidget)
focusedWidget = i;
@@ -221,7 +223,7 @@ namespace gcn
// i is a counter that ensures that the following loop
// won't get stuck in an infinite loop
- i = static_cast<int>(mWidgets.size());
+ i = sz;
do
{
-- focusedWidget;
@@ -235,7 +237,7 @@ namespace gcn
-- i;
if (focusedWidget <= 0)
- focusedWidget = static_cast<int>(mWidgets.size() - 1);
+ focusedWidget = sz - 1;
if (focusedWidget == focused)
return;
@@ -340,7 +342,8 @@ namespace gcn
int i;
int focusedWidget = -1;
- for (i = 0; i < static_cast<int>(mWidgets.size()); ++ i)
+ const int sz = static_cast<int>(mWidgets.size());
+ for (i = 0; i < sz; ++ i)
{
if (mWidgets[i] == mFocusedWidget)
focusedWidget = i;
@@ -350,7 +353,7 @@ namespace gcn
// i is a counter that ensures that the following loop
// won't get stuck in an infinite loop
- i = static_cast<int>(mWidgets.size());
+ i = sz;
do
{
++ focusedWidget;
@@ -363,7 +366,7 @@ namespace gcn
-- i;
- if (focusedWidget >= static_cast<int>(mWidgets.size()))
+ if (focusedWidget >= sz)
focusedWidget = 0;
if (focusedWidget == focused)
@@ -408,7 +411,8 @@ namespace gcn
int i;
int focusedWidget = -1;
- for (i = 0; i < static_cast<int>(mWidgets.size()); ++ i)
+ const int sz = static_cast<int>(mWidgets.size());
+ for (i = 0; i < sz; ++ i)
{
if (mWidgets[i] == mFocusedWidget)
focusedWidget = i;
@@ -418,7 +422,7 @@ namespace gcn
// i is a counter that ensures that the following loop
// won't get stuck in an infinite loop
- i = static_cast<int>(mWidgets.size());
+ i = sz;
do
{
-- focusedWidget;
@@ -432,7 +436,7 @@ namespace gcn
-- i;
if (focusedWidget <= 0)
- focusedWidget = static_cast<int>(mWidgets.size() - 1);
+ focusedWidget = sz - 1;
if (focusedWidget == focused)
return;