From cd24ed1c6c5aab358b4f18d262bd4c00c0ebfe96 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 16 Sep 2012 19:28:16 +0300 Subject: Add const to variables with type size_t. --- src/gui/widgets/browserbox.cpp | 6 +++--- src/gui/widgets/chattab.cpp | 4 ++-- src/gui/widgets/textbox.cpp | 3 +-- src/gui/widgets/whispertab.cpp | 8 ++++---- 4 files changed, 10 insertions(+), 11 deletions(-) (limited to 'src/gui/widgets') diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index c657d1e0e..18a9df3e2 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -121,8 +121,8 @@ void BrowserBox::addRow(const std::string &row, const bool atTop) const int sz = static_cast(mTextRows.size()); while (idx1 != std::string::npos) { - size_t idx2 = tmp.find("|", idx1); - size_t idx3 = tmp.find("@@", idx2); + const size_t idx2 = tmp.find("|", idx1); + const size_t idx3 = tmp.find("@@", idx2); if (idx2 == std::string::npos || idx3 == std::string::npos) break; @@ -560,7 +560,7 @@ int BrowserBox::calcHeight() } } - size_t len = (end == std::string::npos) ? end : end - start; + const size_t len = (end == std::string::npos) ? end : end - start; if (start >= row.length()) break; diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index a78d1f636..d71f7f640 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -114,7 +114,7 @@ void ChatTab::chatLog(std::string line, Own own, tmp.nick = ""; tmp.text = line; - size_t pos = line.find(" : "); + const size_t pos = line.find(" : "); if (pos != std::string::npos) { if (line.length() <= pos + 3) @@ -345,7 +345,7 @@ void ChatTab::chatInput(const std::string &message) while (start + 1 < msg.size() && start != std::string::npos && msg[start + 1] != '@') { - size_t end = msg.find(']', start); + const size_t end = msg.find(']', start); if (start + 1 != end && end != std::string::npos) { // Catch multiple embeds and ignore them diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp index 541308e5e..3254f9f28 100644 --- a/src/gui/widgets/textbox.cpp +++ b/src/gui/widgets/textbox.cpp @@ -52,13 +52,12 @@ void TextBox::setTextWrapped(const std::string &text, const int minDimension) mMinWidth = minDimension; std::stringstream wrappedStream; - size_t spacePos; size_t newlinePos; size_t lastNewlinePos = 0; int minWidth = 0; int xpos; - spacePos = text.rfind(" ", text.size()); + size_t spacePos = text.rfind(" ", text.size()); if (spacePos != std::string::npos) { diff --git a/src/gui/widgets/whispertab.cpp b/src/gui/widgets/whispertab.cpp index cc4db6a87..2126f3c7b 100644 --- a/src/gui/widgets/whispertab.cpp +++ b/src/gui/widgets/whispertab.cpp @@ -80,10 +80,10 @@ void WhisperTab::handleCommand(const std::string &msg) return; } - size_t pos = msg.find(' '); - std::string type(msg, 0, pos); - std::string args(msg, pos == std::string::npos - ? msg.size() : pos + 1); + const size_t pos = msg.find(' '); + const std::string type(msg, 0, pos); + const std::string args(msg, pos == std::string::npos + ? msg.size() : pos + 1); if (type == "me") { -- cgit v1.2.3-70-g09d2