summaryrefslogtreecommitdiff
path: root/src/gui
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/gui
parentd0ccffd7db79f5dbff6f2cb4f8b77a8bb3435e57 (diff)
downloadmanaverse-a9d1aaa774b9e986b8ee3c6cb1e7baa1d9ba3ea5.tar.gz
manaverse-a9d1aaa774b9e986b8ee3c6cb1e7baa1d9ba3ea5.tar.bz2
manaverse-a9d1aaa774b9e986b8ee3c6cb1e7baa1d9ba3ea5.tar.xz
manaverse-a9d1aaa774b9e986b8ee3c6cb1e7baa1d9ba3ea5.zip
improve size() methods usage.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/widgets/characterviewsmall.cpp2
-rw-r--r--src/gui/widgets/chattab.cpp9
-rw-r--r--src/gui/widgets/textbox.cpp10
3 files changed, 11 insertions, 10 deletions
diff --git a/src/gui/widgets/characterviewsmall.cpp b/src/gui/widgets/characterviewsmall.cpp
index fa654b94d..6cdb01c7e 100644
--- a/src/gui/widgets/characterviewsmall.cpp
+++ b/src/gui/widgets/characterviewsmall.cpp
@@ -67,7 +67,7 @@ void CharacterViewSmall::show(const int i)
if (i >= sz)
mSelected = 0;
else if (i < 0)
- mSelected = mCharacterEntries->size() - 1;
+ mSelected = sz - 1;
else
mSelected = i;
mSelectedEntry = (*mCharacterEntries)[mSelected];
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp
index 03d1aaf78..37e94ef1b 100644
--- a/src/gui/widgets/chattab.cpp
+++ b/src/gui/widgets/chattab.cpp
@@ -346,7 +346,8 @@ void ChatTab::chatInput(const std::string &message)
// Check for item link
size_t start = msg.find('[');
- while (start + 1 < msg.size() && start != std::string::npos
+ size_t sz = msg.size();
+ while (start + 1 < sz && start != std::string::npos
&& msg[start + 1] != '@')
{
const size_t end = msg.find(']', start);
@@ -360,9 +361,8 @@ void ChatTab::chatInput(const std::string &message)
start = msg.find('[', start + 1);
}
- std::string temp("");
- if (start + 1 < msg.length() && end < msg.length()
- && end > start + 1)
+ std::string temp;
+ if (start + 1 < sz && end < sz && end > start + 1)
{
temp = msg.substr(start + 1, end - start - 1);
@@ -373,6 +373,7 @@ void ChatTab::chatInput(const std::string &message)
msg.insert(start + 1, "|");
msg.insert(start + 1, toString(itemInfo.getId()));
msg.insert(start + 1, "@@");
+ sz = msg.size();
}
}
}
diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp
index 4eccbe76c..660655033 100644
--- a/src/gui/widgets/textbox.cpp
+++ b/src/gui/widgets/textbox.cpp
@@ -89,13 +89,14 @@ void TextBox::setTextWrapped(const std::string &text, const int minDimension)
xpos = 0;
gcn::Font *const font = getFont();
const int spaceWidth = font->getWidth(" ");
+ size_t sz = line.size();
do
{
spacePos = line.find(" ", lastSpacePos);
if (spacePos == std::string::npos)
- spacePos = line.size();
+ spacePos = sz;
const std::string word =
line.substr(lastSpacePos, spacePos - lastSpacePos);
@@ -130,14 +131,13 @@ void TextBox::setTextWrapped(const std::string &text, const int minDimension)
mMinWidth = minWidth;
wrappedStream.clear();
wrappedStream.str("");
-// spacePos = 0;
lastNewlinePos = 0;
newlinePos = text.find("\n", lastNewlinePos);
if (newlinePos == std::string::npos)
newlinePos = textSize;
line = text.substr(lastNewlinePos, newlinePos -
lastNewlinePos);
-// width = 0;
+ sz = line.size();
break;
}
else
@@ -148,14 +148,14 @@ void TextBox::setTextWrapped(const std::string &text, const int minDimension)
}
lastSpacePos = spacePos + 1;
}
- while (spacePos != line.size());
+ while (spacePos != sz);
if (text.find("\n", lastNewlinePos) != std::string::npos)
wrappedStream << "\n";
lastNewlinePos = newlinePos + 1;
}
- while (newlinePos != text.size());
+ while (newlinePos != textSize);
if (xpos > minWidth)
minWidth = xpos;