summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-07-01 12:52:33 +0300
committerAndrei Karas <akaras@inbox.ru>2013-07-01 12:52:33 +0300
commit2213603c14b289ceb5389329f79f7af3cfc44faa (patch)
tree1d60607124a4e77feeeb2e383685873f79fe16c3 /src
parent222d6c7b11263bea997a127ca24b491370e090d6 (diff)
downloadmanaverse-2213603c14b289ceb5389329f79f7af3cfc44faa.tar.gz
manaverse-2213603c14b289ceb5389329f79f7af3cfc44faa.tar.bz2
manaverse-2213603c14b289ceb5389329f79f7af3cfc44faa.tar.xz
manaverse-2213603c14b289ceb5389329f79f7af3cfc44faa.zip
improve size() usage in textbox.
Diffstat (limited to 'src')
-rw-r--r--src/gui/widgets/textbox.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp
index c1bf84d85..4eccbe76c 100644
--- a/src/gui/widgets/textbox.cpp
+++ b/src/gui/widgets/textbox.cpp
@@ -57,7 +57,8 @@ void TextBox::setTextWrapped(const std::string &text, const int minDimension)
// point and try to beat it
mMinWidth = minDimension;
- size_t spacePos = text.rfind(" ", text.size());
+ const size_t textSize = text.size();
+ size_t spacePos = text.rfind(" ", textSize);
if (spacePos != std::string::npos)
{
@@ -80,7 +81,7 @@ void TextBox::setTextWrapped(const std::string &text, const int minDimension)
newlinePos = text.find("\n", lastNewlinePos);
if (newlinePos == std::string::npos)
- newlinePos = text.size();
+ newlinePos = textSize;
std::string line =
text.substr(lastNewlinePos, newlinePos - lastNewlinePos);
@@ -133,7 +134,7 @@ void TextBox::setTextWrapped(const std::string &text, const int minDimension)
lastNewlinePos = 0;
newlinePos = text.find("\n", lastNewlinePos);
if (newlinePos == std::string::npos)
- newlinePos = text.size();
+ newlinePos = textSize;
line = text.substr(lastNewlinePos, newlinePos -
lastNewlinePos);
// width = 0;
@@ -314,8 +315,9 @@ void TextBox::keyPressed(gcn::KeyEvent& keyEvent)
/ getFont()->getHeight();
mCaretRow += rowsPerPage;
- 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;
}
break;
}