summaryrefslogtreecommitdiff
path: root/src/guichan/widgets/textbox.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-08-09 23:41:59 +0300
committerAndrei Karas <akaras@inbox.ru>2013-08-09 23:41:59 +0300
commita9d1aaa774b9e986b8ee3c6cb1e7baa1d9ba3ea5 (patch)
tree20a5024ce03d3b0abedd76378c534f4150af0ee9 /src/guichan/widgets/textbox.cpp
parentd0ccffd7db79f5dbff6f2cb4f8b77a8bb3435e57 (diff)
downloadplus-a9d1aaa774b9e986b8ee3c6cb1e7baa1d9ba3ea5.tar.gz
plus-a9d1aaa774b9e986b8ee3c6cb1e7baa1d9ba3ea5.tar.bz2
plus-a9d1aaa774b9e986b8ee3c6cb1e7baa1d9ba3ea5.tar.xz
plus-a9d1aaa774b9e986b8ee3c6cb1e7baa1d9ba3ea5.zip
improve size() methods usage.
Diffstat (limited to 'src/guichan/widgets/textbox.cpp')
-rw-r--r--src/guichan/widgets/textbox.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/guichan/widgets/textbox.cpp b/src/guichan/widgets/textbox.cpp
index 3f1c51402..512471391 100644
--- a/src/guichan/widgets/textbox.cpp
+++ b/src/guichan/widgets/textbox.cpp
@@ -137,8 +137,9 @@ namespace gcn
{
mCaretRow = mouseEvent.getY() / getFont()->getHeight();
- if (mCaretRow >= static_cast<int>(mTextRows.size()))
- mCaretRow = static_cast<int>(mTextRows.size() - 1);
+ const int sz = static_cast<int>(mTextRows.size());
+ if (mCaretRow >= sz)
+ mCaretRow = sz - 1;
mCaretColumn = getFont()->getStringIndexAt(
mTextRows[mCaretRow], mouseEvent.getX());
@@ -210,8 +211,9 @@ namespace gcn
{
mCaretRow = row;
- if (mCaretRow >= static_cast<int>(mTextRows.size()))
- mCaretRow = static_cast<int>(mTextRows.size() - 1);
+ const int sz = static_cast<int>(mTextRows.size());
+ if (mCaretRow >= sz)
+ mCaretRow = sz - 1;
if (mCaretRow < 0)
mCaretRow = 0;
@@ -228,8 +230,9 @@ namespace gcn
{
mCaretColumn = column;
- if (mCaretColumn > static_cast<int>(mTextRows[mCaretRow].size()))
- mCaretColumn = static_cast<int>(mTextRows[mCaretRow].size());
+ const int sz = static_cast<int>(mTextRows[mCaretRow].size());
+ if (mCaretColumn > sz)
+ mCaretColumn = sz;
if (mCaretColumn < 0)
mCaretColumn = 0;