summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-09-16 19:28:16 +0300
committerAndrei Karas <akaras@inbox.ru>2012-09-16 19:28:16 +0300
commitcd24ed1c6c5aab358b4f18d262bd4c00c0ebfe96 (patch)
treefdda7e2c3d93b35771f6eb79c22dce9301082f19
parentf8fc3380197c078a6dcff02351d835c3022411e1 (diff)
downloadmanaverse-cd24ed1c6c5aab358b4f18d262bd4c00c0ebfe96.tar.gz
manaverse-cd24ed1c6c5aab358b4f18d262bd4c00c0ebfe96.tar.bz2
manaverse-cd24ed1c6c5aab358b4f18d262bd4c00c0ebfe96.tar.xz
manaverse-cd24ed1c6c5aab358b4f18d262bd4c00c0ebfe96.zip
Add const to variables with type size_t.
-rw-r--r--src/actorspritemanager.cpp2
-rw-r--r--src/being.cpp4
-rw-r--r--src/client.cpp3
-rw-r--r--src/commandhandler.cpp11
-rw-r--r--src/gui/chatwindow.cpp15
-rw-r--r--src/gui/helpwindow.cpp2
-rw-r--r--src/gui/shopwindow.cpp2
-rw-r--r--src/gui/whoisonline.cpp11
-rw-r--r--src/gui/widgets/browserbox.cpp6
-rw-r--r--src/gui/widgets/chattab.cpp4
-rw-r--r--src/gui/widgets/textbox.cpp3
-rw-r--r--src/gui/widgets/whispertab.cpp8
-rw-r--r--src/guildmanager.cpp4
-rw-r--r--src/inputmanager.cpp5
-rw-r--r--src/map.cpp6
-rw-r--r--src/net/ea/chathandler.cpp6
-rw-r--r--src/net/ea/guildhandler.cpp2
-rw-r--r--src/resources/dye.cpp9
-rw-r--r--src/resources/resourcemanager.cpp6
-rw-r--r--src/resources/spritedef.cpp4
-rw-r--r--src/spellmanager.cpp4
-rw-r--r--src/units.cpp2
-rw-r--r--src/utils/mkdir.cpp2
-rw-r--r--src/utils/paths.cpp2
-rw-r--r--src/utils/stringutils.cpp20
-rw-r--r--src/utils/translation/translationmanager.cpp2
26 files changed, 68 insertions, 77 deletions
diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp
index 82ee868cc..a50e328d1 100644
--- a/src/actorspritemanager.cpp
+++ b/src/actorspritemanager.cpp
@@ -1450,7 +1450,7 @@ void ActorSpriteManager::parseLevels(std::string levels) const
std::string part = levels.substr(f, pos - f);
if (part.empty())
break;
- size_t bktPos = part.rfind("(");
+ const size_t bktPos = part.rfind("(");
if (bktPos != std::string::npos)
{
Being *const being = findBeingByName(part.substr(0, bktPos),
diff --git a/src/being.cpp b/src/being.cpp
index 30541a590..5e52901f6 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -2512,7 +2512,7 @@ Equipment *Being::getEquipment()
void Being::undressItemById(const int id)
{
- size_t sz = mSpriteIDs.size();
+ const size_t sz = mSpriteIDs.size();
for (size_t f = 0; f < sz; f ++)
{
@@ -2680,7 +2680,7 @@ BeingEquipBackend::BeingEquipBackend(Being *const being):
memset(mEquipment, 0, sizeof(mEquipment));
if (being)
{
- size_t sz = being->mSpriteIDs.size();
+ const size_t sz = being->mSpriteIDs.size();
for (unsigned f = 0; f < sz; f ++)
{
diff --git a/src/client.cpp b/src/client.cpp
index 5ef48b5d4..c5369127b 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -1859,8 +1859,7 @@ void Client::initUpdatesDir()
mUpdateHost.resize(mUpdateHost.size() - 1);
// Parse out any "http://" or "ftp://", and set the updates directory
- size_t pos;
- pos = mUpdateHost.find("://");
+ const size_t pos = mUpdateHost.find("://");
if (pos != mUpdateHost.npos)
{
if (pos + 3 < mUpdateHost.length() && !mUpdateHost.empty())
diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp
index bdce12dea..6140b398e 100644
--- a/src/commandhandler.cpp
+++ b/src/commandhandler.cpp
@@ -88,11 +88,10 @@ void CommandHandler::handleCommands(const std::string &command,
void CommandHandler::handleCommand(const std::string &command,
ChatTab *const tab)
{
- size_t pos = command.find(' ');
- std::string type(command, 0, pos);
+ const size_t pos = command.find(' ');
+ const std::string type(command, 0, pos);
std::string args(command, pos == std::string::npos
? command.size() : pos + 1);
-
args = trim(args);
if (command == "closeall")
@@ -377,9 +376,9 @@ void CommandHandler::handleJoin(const std::string &args, ChatTab *const tab)
if (!tab)
return;
- size_t pos = args.find(' ');
- std::string name(args, 0, pos);
- std::string password(args, pos + 1);
+ const size_t pos = args.find(' ');
+ const std::string name(args, 0, pos);
+ const std::string password(args, pos + 1);
tab->chatLog(strprintf(_("Requesting to join channel %s."), name.c_str()));
Net::getChatHandler()->enterChannel(name, password);
}
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index 9ea0bb383..fdc6169ed 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -1055,7 +1055,7 @@ void ChatWindow::addWhisper(const std::string &nick,
{
std::string msg = mes;
std::string nick2;
- size_t idx = mes.find(":");
+ const size_t idx = mes.find(":");
if (idx != std::string::npos && idx > 0)
{
nick2 = msg.substr(0, idx);
@@ -1298,7 +1298,7 @@ std::string ChatWindow::autoComplete(StringVect &names,
std::string name = *i;
toLower(name);
- size_t pos = name.find(partName, 0);
+ const size_t pos = name.find(partName, 0);
if (pos == 0)
{
if (newName != "")
@@ -1330,8 +1330,7 @@ std::string ChatWindow::autoComplete(std::string partName,
while (i != i_end)
{
std::string line = *i;
- size_t pos = line.find(partName, 0);
- if (pos == 0)
+ if (line.find(partName, 0) == 0)
nameList.push_back(line);
++i;
}
@@ -1388,7 +1387,7 @@ void ChatWindow::resortChatLog(std::string line, Own own,
return;
}
- size_t idx = line.find(": \302\202");
+ const size_t idx = line.find(": \302\202");
if (idx != std::string::npos)
{
line = line.erase(idx + 2, 2);
@@ -1396,13 +1395,13 @@ void ChatWindow::resortChatLog(std::string line, Own own,
return;
}
- size_t idx1 = line.find("@@");
+ const size_t idx1 = line.find("@@");
if (idx1 != std::string::npos)
{
- size_t idx2 = line.find("|", idx1);
+ const size_t idx2 = line.find("|", idx1);
if (idx2 != std::string::npos)
{
- size_t idx3 = line.find("@@", idx2);
+ const size_t idx3 = line.find("@@", idx2);
if (idx3 != std::string::npos)
{
if (line.find("http", idx1) != idx1 + 2)
diff --git a/src/gui/helpwindow.cpp b/src/gui/helpwindow.cpp
index 61bd54c8c..6dbb6ec09 100644
--- a/src/gui/helpwindow.cpp
+++ b/src/gui/helpwindow.cpp
@@ -136,7 +136,7 @@ void HelpWindow::loadTags()
it != it_end; ++ it)
{
const std::string &str = *it;
- size_t idx = str.find('|');
+ const size_t idx = str.find('|');
if (idx != std::string::npos)
mTagFileMap[str.substr(idx + 1)].insert(str.substr(0, idx));
}
diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp
index 386652a93..016ad2d26 100644
--- a/src/gui/shopwindow.cpp
+++ b/src/gui/shopwindow.cpp
@@ -693,7 +693,7 @@ void ShopWindow::processRequest(std::string nick, std::string data,
if (!inv)
return;
- size_t idx = data.find(" ");
+ const size_t idx = data.find(" ");
if (idx == std::string::npos)
return;
diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp
index 0747b4276..747691ad3 100644
--- a/src/gui/whoisonline.cpp
+++ b/src/gui/whoisonline.cpp
@@ -241,7 +241,7 @@ void WhoIsOnline::updateWindow(std::vector<OnlinePlayer*> &friends,
void WhoIsOnline::loadList(std::vector<OnlinePlayer*> &list)
{
mBrowserBox->clearRows();
- size_t numOnline = list.size();
+ const size_t numOnline = list.size();
std::vector<OnlinePlayer*> friends;
std::vector<OnlinePlayer*> neutral;
std::vector<OnlinePlayer*> disregard;
@@ -353,13 +353,10 @@ void WhoIsOnline::loadWebList()
trim(lineStr);
if (listStarted == true)
{
- size_t found;
- found = lineStr.find(" users are online.");
- if (found == std::string::npos)
+ if (lineStr.find(" users are online.") == std::string::npos)
{
int level = 0;
- size_t pos = 0;
if (lineStr.length() > 24)
{
nick = lineStr.substr(0, 24);
@@ -373,7 +370,7 @@ void WhoIsOnline::loadWebList()
trim(nick);
bool isGM(false);
- pos = lineStr.find(gmText, 0);
+ size_t pos = lineStr.find(gmText, 0);
if (pos != std::string::npos)
{
lineStr = lineStr.substr(pos + gmText.length());
@@ -477,7 +474,7 @@ size_t WhoIsOnline::memoryWrite(void *ptr, size_t size,
return 0;
WhoIsOnline *wio = reinterpret_cast<WhoIsOnline *>(stream);
- size_t totalMem = size * nmemb;
+ const size_t totalMem = size * nmemb;
wio->mMemoryBuffer = static_cast<char*>(realloc(wio->mMemoryBuffer,
wio->mDownloadedBytes + totalMem));
if (wio->mMemoryBuffer)
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<int>(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")
{
diff --git a/src/guildmanager.cpp b/src/guildmanager.cpp
index 29b438fea..df5c4f6da 100644
--- a/src/guildmanager.cpp
+++ b/src/guildmanager.cpp
@@ -272,7 +272,7 @@ bool GuildManager::process(std::string msg)
if (!guild)
return false;
// logger->log("welcome message: %s", msg.c_str());
- size_t pos = msg.find("! (");
+ const size_t pos = msg.find("! (");
if (pos == std::string::npos)
return false;
msg = msg.substr(0, pos);
@@ -400,7 +400,7 @@ bool GuildManager::process(std::string msg)
}
if (mTab)
{
- size_t pos = msg.find(": ", 0);
+ const size_t pos = msg.find(": ", 0);
if (pos != std::string::npos)
{
std::string sender_name = ((pos == std::string::npos)
diff --git a/src/inputmanager.cpp b/src/inputmanager.cpp
index 969867a83..a5994907e 100644
--- a/src/inputmanager.cpp
+++ b/src/inputmanager.cpp
@@ -228,13 +228,11 @@ void InputManager::makeDefault(const int i)
bool InputManager::hasConflicts(int &key1, int &key2) const
{
- size_t i;
- size_t j;
/**
* No need to parse the square matrix: only check one triangle
* that's enough to detect conflicts
*/
- for (i = 0; i < Input::KEY_TOTAL; i++)
+ for (int i = 0; i < Input::KEY_TOTAL; i++)
{
if (!*keyData[i].configField)
continue;
@@ -244,6 +242,7 @@ bool InputManager::hasConflicts(int &key1, int &key2) const
if (mKey[i].values[i2].value == Input::KEY_NO_VALUE)
continue;
+ size_t j;
for (j = i, j++; j < Input::KEY_TOTAL; j++)
{
diff --git a/src/map.cpp b/src/map.cpp
index 29d9a6821..087a16a55 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -727,10 +727,8 @@ const std::string Map::getName() const
const std::string Map::getFilename() const
{
std::string fileName = getProperty("_filename");
- size_t lastSlash = fileName.rfind("/") + 1;
- size_t lastDot = fileName.rfind(".");
-
- return fileName.substr(lastSlash, lastDot - lastSlash);
+ const size_t lastSlash = fileName.rfind("/") + 1;
+ return fileName.substr(lastSlash, fileName.rfind(".") - lastSlash);
}
Position Map::checkNodeOffsets(int radius, const unsigned char walkMask,
diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp
index 4d761a1ce..7cad30837 100644
--- a/src/net/ea/chathandler.cpp
+++ b/src/net/ea/chathandler.cpp
@@ -266,9 +266,9 @@ void ChatHandler::processBeingChat(Net::MessageIn &msg)
if (being->getType() == Being::PLAYER)
being->setTalkTime();
- size_t pos = chatMsg.find(" : ", 0);
+ const size_t pos = chatMsg.find(" : ", 0);
std::string sender_name = ((pos == std::string::npos)
- ? "" : chatMsg.substr(0, pos));
+ ? "" : chatMsg.substr(0, pos));
if (sender_name != being->getName() && being->getType() == Being::PLAYER)
{
@@ -307,7 +307,7 @@ void ChatHandler::processChat(Net::MessageIn &msg, bool normalChat)
return;
std::string chatMsg = msg.readRawString(chatMsgLength);
- size_t pos = chatMsg.find(" : ", 0);
+ const size_t pos = chatMsg.find(" : ", 0);
if (normalChat)
{
diff --git a/src/net/ea/guildhandler.cpp b/src/net/ea/guildhandler.cpp
index 9d4126106..5a6426e16 100644
--- a/src/net/ea/guildhandler.cpp
+++ b/src/net/ea/guildhandler.cpp
@@ -543,7 +543,7 @@ void GuildHandler::processGuildMessage(Net::MessageIn &msg)
{
std::string chatMsg = msg.readString(msgLength);
- size_t pos = chatMsg.find(" : ", 0);
+ const size_t pos = chatMsg.find(" : ", 0);
if (pos != std::string::npos)
{
std::string sender_name = ((pos == std::string::npos)
diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp
index 4cedafd4e..4b5c1268c 100644
--- a/src/resources/dye.cpp
+++ b/src/resources/dye.cpp
@@ -282,10 +282,11 @@ Dye::Dye(const std::string &description)
if (description.empty())
return;
- size_t next_pos = 0, length = description.length();
+ size_t next_pos = 0;
+ const size_t length = description.length();
do
{
- size_t pos = next_pos;
+ const size_t pos = next_pos;
next_pos = description.find(';', pos);
if (next_pos == std::string::npos)
@@ -367,7 +368,7 @@ void Dye::instantiate(std::string &target, const std::string &palettes)
size_t last_pos = target.length(), pal_pos = 0;
do
{
- size_t pos = next_pos;
+ const size_t pos = next_pos;
next_pos = target.find(';', pos);
if (next_pos == std::string::npos)
@@ -375,7 +376,7 @@ void Dye::instantiate(std::string &target, const std::string &palettes)
if (next_pos == pos + 1 && pal_pos != std::string::npos)
{
- size_t pal_next_pos = palettes.find(';', pal_pos);
+ const size_t pal_next_pos = palettes.find(';', pal_pos);
s << target[pos] << ':';
if (pal_next_pos == std::string::npos)
{
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index 2e6a381fa..d6e66ff7e 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -263,7 +263,7 @@ void ResourceManager::searchAndAddArchives(const std::string &path,
for (char **i = list; *i; i++)
{
- size_t len = strlen(*i);
+ const size_t len = strlen(*i);
if (len > ext.length() && !ext.compare((*i) + (len - ext.length())))
{
@@ -288,7 +288,7 @@ void ResourceManager::searchAndRemoveArchives(const std::string &path,
for (char **i = list; *i; i++)
{
- size_t len = strlen(*i);
+ const size_t len = strlen(*i);
if (len > ext.length() && !ext.compare((*i) + (len - ext.length())))
{
@@ -481,7 +481,7 @@ struct DyedImageLoader
return nullptr;
std::string path = rl->path;
- size_t p = path.find('|');
+ const size_t p = path.find('|');
Dye *d = nullptr;
if (p != std::string::npos)
{
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp
index f54a332a7..9e8e2cc90 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -76,7 +76,7 @@ unsigned SpriteDef::findNumber(const unsigned num) const
SpriteDef *SpriteDef::load(const std::string &animationFile, const int variant)
{
- size_t pos = animationFile.find('|');
+ const size_t pos = animationFile.find('|');
std::string palettes;
if (pos != std::string::npos)
palettes = animationFile.substr(pos + 1);
@@ -334,7 +334,7 @@ void SpriteDef::loadAnimation(const XmlNodePtr animationNode,
it != it_end; ++ it)
{
std::string str = *it;
- size_t idx = str.find("-");
+ const size_t idx = str.find("-");
if (str == "p")
{
animation->addPause(delay, rand);
diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp
index 6111d3a9b..746331851 100644
--- a/src/spellmanager.cpp
+++ b/src/spellmanager.cpp
@@ -362,11 +362,11 @@ std::string SpellManager::autoComplete(std::string partName)
while (i != i_end)
{
const TextCommand *const cmd = *i;
- std::string line = cmd->getCommand();
+ const std::string line = cmd->getCommand();
if (line != "")
{
- size_t pos = line.find(partName, 0);
+ const size_t pos = line.find(partName, 0);
if (pos == 0)
{
if (newName != "")
diff --git a/src/units.cpp b/src/units.cpp
index 52093c057..3a2a5dace 100644
--- a/src/units.cpp
+++ b/src/units.cpp
@@ -265,7 +265,7 @@ std::string Units::formatWeight(const int value)
static std::string splitNumber(std::string str, const std::string &separator)
{
std::string lastPart;
- size_t point = str.find(".");
+ const size_t point = str.find(".");
if (point != std::string::npos)
{
lastPart = str.substr(point);
diff --git a/src/utils/mkdir.cpp b/src/utils/mkdir.cpp
index e07b3979f..c7cacf0cb 100644
--- a/src/utils/mkdir.cpp
+++ b/src/utils/mkdir.cpp
@@ -113,7 +113,7 @@ int mkdir_r(const char *const pathname)
/// Create a directory, making leading components first if necessary
int mkdir_r(const char *const pathname)
{
- size_t len = static_cast<int>(strlen(pathname));
+ const size_t len = static_cast<int>(strlen(pathname));
char *tmp = new char[len + 2];
char *p;
diff --git a/src/utils/paths.cpp b/src/utils/paths.cpp
index 05a00c1ea..11ad19a2e 100644
--- a/src/utils/paths.cpp
+++ b/src/utils/paths.cpp
@@ -88,7 +88,7 @@ std::string &fixDirSeparators(std::string &str)
std::string removeLast(std::string str)
{
size_t pos2 = str.rfind("/");
- size_t pos3 = str.rfind("\\");
+ const size_t pos3 = str.rfind("\\");
if (pos3 != std::string::npos)
{
if (pos2 == std::string::npos || pos3 > pos2)
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index 2daad464b..2ceab5b92 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -186,7 +186,7 @@ const std::string findSameSubstringI(const std::string &s1,
toLower(str1);
toLower(str2);
- size_t minLength = str1.length() > str2.length()
+ const size_t minLength = str1.length() > str2.length()
? str2.length() : str1.length();
for (size_t f = 0; f < minLength; f ++)
{
@@ -256,11 +256,11 @@ unsigned int decodeStr(const std::string &str)
std::string extractNameFromSprite(std::string str)
{
- size_t pos1 = str.rfind(".");
+ const size_t pos1 = str.rfind(".");
if (pos1 != std::string::npos)
{
size_t pos2 = str.rfind("/");
- size_t pos3 = str.rfind("\\");
+ const size_t pos3 = str.rfind("\\");
if (pos3 != std::string::npos)
{
if (pos2 == std::string::npos || pos3 > pos2)
@@ -278,12 +278,12 @@ std::string extractNameFromSprite(std::string str)
std::string removeSpriteIndex(std::string str)
{
- size_t pos1 = str.rfind("[");
+ const size_t pos1 = str.rfind("[");
if (pos1 != std::string::npos)
{
size_t pos2 = str.rfind("/");
- size_t pos3 = str.rfind("\\");
+ const size_t pos3 = str.rfind("\\");
if (pos3 != std::string::npos)
{
if (pos2 == std::string::npos || pos3 > pos2)
@@ -321,7 +321,7 @@ void getSafeUtf8String(std::string text, char *const buf)
std::string getFileName(std::string path)
{
size_t pos1 = path.rfind("/");
- size_t pos2 = path.rfind("\\");
+ const size_t pos2 = path.rfind("\\");
if (pos1 == std::string::npos)
pos1 = pos2;
else if (pos2 != std::string::npos && pos2 > pos1)
@@ -335,7 +335,7 @@ std::string getFileName(std::string path)
std::string getFileDir(std::string path)
{
size_t pos1 = path.rfind("/");
- size_t pos2 = path.rfind("\\");
+ const size_t pos2 = path.rfind("\\");
if (pos1 == std::string::npos)
pos1 = pos2;
else if (pos2 != std::string::npos && pos2 > pos1)
@@ -477,7 +477,7 @@ std::string combineDye(std::string file, std::string dye)
{
if (dye.empty())
return file;
- size_t pos = file.find_last_of("|");
+ const size_t pos = file.find_last_of("|");
if (pos != std::string::npos)
return file.substr(0, pos) + "|" + dye;
return file + "|" + dye;
@@ -488,7 +488,7 @@ std::string combineDye2(std::string file, std::string dye)
if (dye.empty())
return file;
- size_t pos = file.find_last_of("|");
+ const size_t pos = file.find_last_of("|");
if (pos != std::string::npos)
{
std::string dye1 = file.substr(pos + 1);
@@ -611,7 +611,7 @@ bool findCutFirst(std::string &str1, std::string str2)
std::string &removeProtocol(std::string &url)
{
- size_t i = url.find("://");
+ const size_t i = url.find("://");
if (i != std::string::npos)
url = url.substr(i + 3);
return url;
diff --git a/src/utils/translation/translationmanager.cpp b/src/utils/translation/translationmanager.cpp
index 110353baf..fe5d0951a 100644
--- a/src/utils/translation/translationmanager.cpp
+++ b/src/utils/translation/translationmanager.cpp
@@ -109,7 +109,7 @@ bool TranslationManager::translateFile(const std::string &fileName,
{
if (pos1 == oldPos1)
break; // detected infinite loop
- size_t pos2 = str.find(">>", pos1 + 2);
+ const size_t pos2 = str.find(">>", pos1 + 2);
if (pos2 == std::string::npos)
break;
const std::string key = str.substr(pos1 + 2, pos2 - pos1 - 2);