diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/widgets/avatarlistbox.cpp | 20 | ||||
-rw-r--r-- | src/gui/widgets/browserbox.cpp | 10 | ||||
-rw-r--r-- | src/gui/widgets/chattab.cpp | 18 | ||||
-rw-r--r-- | src/gui/widgets/setupitem.cpp | 4 | ||||
-rw-r--r-- | src/net/messagein.cpp | 30 | ||||
-rw-r--r-- | src/resources/atlasmanager.cpp | 6 | ||||
-rw-r--r-- | src/resources/dye.cpp | 2 | ||||
-rw-r--r-- | src/resources/emotedb.cpp | 8 | ||||
-rw-r--r-- | src/resources/itemdb.cpp | 12 | ||||
-rw-r--r-- | src/resources/iteminfo.cpp | 2 | ||||
-rw-r--r-- | src/resources/mapdb.cpp | 2 | ||||
-rw-r--r-- | src/resources/mapreader.cpp | 6 | ||||
-rw-r--r-- | src/resources/resourcemanager.cpp | 28 | ||||
-rw-r--r-- | src/resources/spritedef.cpp | 6 | ||||
-rw-r--r-- | src/resources/wallpaper.cpp | 2 | ||||
-rw-r--r-- | src/test/testmain.cpp | 28 | ||||
-rw-r--r-- | src/utils/paths.cpp | 15 | ||||
-rw-r--r-- | src/utils/process.cpp | 8 | ||||
-rw-r--r-- | src/utils/stringutils.cpp | 12 |
19 files changed, 112 insertions, 107 deletions
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 0e3135b03..b69664ddd 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -212,12 +212,12 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics) { if (a->getX() != -1) { - text += strprintf(" [%d,%d %s]", a->getX(), a->getY(), - a->getMap().c_str()); + text.append(strprintf(" [%d,%d %s]", a->getX(), a->getY(), + a->getMap().c_str())); } else { - text += strprintf(" [%s]", a->getMap().c_str()); + text.append(strprintf(" [%s]", a->getMap().c_str())); } } @@ -228,10 +228,10 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics) switch (a->getGender()) { case GENDER_FEMALE: - text += strprintf(" \u2640 "); + text.append(" \u2640 "); break; case GENDER_MALE: - text += strprintf(" \u2642 "); + text.append(" \u2642 "); break; default: break; @@ -245,12 +245,12 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics) switch (a->getGender()) { case GENDER_FEMALE: - text += strprintf(" \u2640 %s", - a->getAdditionString().c_str()); + text.append(strprintf(" \u2640 %s", + a->getAdditionString().c_str())); break; case GENDER_MALE: - text += strprintf(" \u2642 %s", - a->getAdditionString().c_str()); + text.append(strprintf(" \u2642 %s", + a->getAdditionString().c_str())); break; default: break; @@ -258,7 +258,7 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics) } else { - text += a->getAdditionString(); + text.append(a->getAdditionString()); } } diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 51b977bbc..bbd31cee7 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -162,7 +162,7 @@ void BrowserBox::addRow(const std::string &row, const bool atTop) bLink.y1 = sz * font->getHeight(); bLink.y2 = bLink.y1 + font->getHeight(); - newRow += tmp.substr(0, idx1); + newRow.append(tmp.substr(0, idx1)); std::string tmp2 = newRow; idx1 = tmp2.find("##"); @@ -180,16 +180,16 @@ void BrowserBox::addRow(const std::string &row, const bool atTop) mLinks.push_back(bLink); linksCount ++; - newRow += "##<" + bLink.caption; + newRow.append("##<").append(bLink.caption); tmp.erase(0, idx3 + 2); if (!tmp.empty()) - newRow += "##>"; + newRow.append("##>"); idx1 = tmp.find("@@"); } - newRow += tmp; + newRow.append(tmp); } // Don't use links and user defined colors else @@ -768,7 +768,7 @@ std::string BrowserBox::getTextAtPos(const int x, const int y) const } else { - str += part.mText; + str.append(part.mText); } } diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index fd336e116..ae18740a9 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -146,30 +146,27 @@ void ChatTab::chatLog(std::string line, Own own, case BY_GM: if (tmp.nick.empty()) { - tmp.nick = std::string(_("Global announcement:")); - tmp.nick += " "; + tmp.nick = std::string(_("Global announcement:")).append(" "); lineColor = "##G"; } else { tmp.nick = strprintf(_("Global announcement from %s:"), - tmp.nick.c_str()); - tmp.nick += " "; + tmp.nick.c_str()).append(" "); lineColor = "##1"; // Equiv. to BrowserBox::RED } break; case BY_PLAYER: - tmp.nick += ": "; + tmp.nick.append(": "); lineColor = "##Y"; break; case BY_OTHER: case BY_UNKNOWN: - tmp.nick += ": "; + tmp.nick.append(": "); lineColor = "##C"; break; case BY_SERVER: - tmp.nick = _("Server:"); - tmp.nick += " "; + tmp.nick = std::string(_("Server:")).append(" "); tmp.text = line; lineColor = "##S"; break; @@ -243,7 +240,8 @@ void ChatTab::chatLog(std::string line, Own own, << ":" << (((t / 60) % 60 < 10) ? "0" : "") << static_cast<int>((t / 60) % 60) << "] "; - line = lineColor + timeStr.str() + tmp.nick + tmp.text; + line = std::string(lineColor).append(timeStr.str()).append( + tmp.nick).append(tmp.text); } if (config.getBoolValue("enableChatLog")) @@ -330,7 +328,7 @@ void ChatTab::chatLog(const std::string &nick, std::string msg) const Own byWho = (nick == player_node->getName() ? BY_PLAYER : BY_OTHER); if (byWho == BY_OTHER && config.getBoolValue("removeColors")) msg = removeColors(msg); - chatLog(nick + " : " + msg, byWho, false, false); + chatLog(std::string(nick).append(" : ").append(msg), byWho, false, false); } void ChatTab::chatInput(const std::string &message) diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index d9071aec4..0e9fa993c 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -501,7 +501,7 @@ void SetupItemLabel::createControls() { const std::string str = " \342\200\225\342\200\225\342\200\225" "\342\200\225\342\200\225 "; - mLabel = new Label(this, str + mText + str); + mLabel = new Label(this, std::string(str).append(mText).append(str)); } else { @@ -1032,7 +1032,7 @@ void SetupItemSound::action(const gcn::ActionEvent &event) if (mSlider->getSelected()) { sound.playGuiSfx(branding.getStringValue("systemsounds") - + mSlider->getSelectedString() + ".ogg"); + .append(mSlider->getSelectedString()).append(".ogg")); } } else diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp index f491e1377..2858368e2 100644 --- a/src/net/messagein.cpp +++ b/src/net/messagein.cpp @@ -69,8 +69,9 @@ void MessageIn::readCoordinates(uint16_t &x, uint16_t &y) } mPos += 3; PacketCounters::incInBytes(3); - DEBUGLOG("readCoordinates: " + toString(static_cast<int>(x)) + "," - + toString(static_cast<int>(y))); + DEBUGLOG(std::string("readCoordinates: ").append(toString( + static_cast<int>(x))).append(",").append(toString( + static_cast<int>(y)))); } uint8_t MessageIn::fromServerDirection(uint8_t serverDir) @@ -124,9 +125,10 @@ void MessageIn::readCoordinates(uint16_t &x, uint16_t &y, uint8_t &direction) } mPos += 3; PacketCounters::incInBytes(3); - DEBUGLOG("readCoordinates: " + toString(static_cast<int>(x)) - + "," + toString(static_cast<int>(y)) + "," + toString( - static_cast<int>(serverDir))); + DEBUGLOG(std::string("readCoordinates: ").append(toString( + static_cast<int>(x))).append(",").append(toString( + static_cast<int>(y))).append(",").append(toString( + static_cast<int>(serverDir)))); } void MessageIn::readCoordinatePair(uint16_t &srcX, uint16_t &srcY, @@ -149,10 +151,11 @@ void MessageIn::readCoordinatePair(uint16_t &srcX, uint16_t &srcY, srcY = static_cast<unsigned short>(temp >> 4); } mPos += 5; - DEBUGLOG("readCoordinatePair: " + toString(static_cast<int>(srcX)) + "," - + toString(static_cast<int>(srcY)) + " " - + toString(static_cast<int>(dstX)) + "," - + toString(static_cast<int>(dstY))); + DEBUGLOG(std::string("readCoordinatePair: ").append(toString( + static_cast<int>(srcX))).append(",").append(toString( + static_cast<int>(srcY))).append(" ").append(toString( + static_cast<int>(dstX))).append(",").append(toString( + static_cast<int>(dstY)))); PacketCounters::incInBytes(5); } @@ -223,8 +226,7 @@ std::string MessageIn::readRawString(int length) if (hiddenPart.length() > 0) { DEBUGLOG("readString2: " + hiddenPart); - - return str + "|" + hiddenPart; + return str.append("|").append(hiddenPart); } } @@ -255,14 +257,14 @@ unsigned char *MessageIn::readBytes(int length) #ifdef ENABLEDEBUGLOG std::string str; for (int f = 0; f < length; f ++) - str += strprintf ("%02x", static_cast<unsigned>(buf[f])); + str.append(strprintf("%02x", static_cast<unsigned>(buf[f]))); str += " "; for (int f = 0; f < length; f ++) { if (buf[f]) - str += strprintf ("%c", buf[f]); + str.append(strprintf("%c", buf[f])); else - str += "_"; + str.append("_"); } logger->dlog("ReadBytes: " + str); #endif diff --git a/src/resources/atlasmanager.cpp b/src/resources/atlasmanager.cpp index ef36eedac..9ff01b9c4 100644 --- a/src/resources/atlasmanager.cpp +++ b/src/resources/atlasmanager.cpp @@ -148,7 +148,8 @@ void AtlasManager::simpleSort(const std::string &name, Image *img = *it; if (img) { - atlas->name = "atlas_" + name + "_" + img->getIdPath(); + atlas->name = std::string("atlas_").append(name).append( + "_").append(img->getIdPath()); break; } } @@ -175,7 +176,8 @@ void AtlasManager::simpleSort(const std::string &name, y = 0; atlases.push_back(atlas); atlas = new TextureAtlas(); - atlas->name = "atlas_" + name + "_" + img->getIdPath(); + atlas->name = std::string("atlas_").append(name).append( + "_").append(img->getIdPath()); } if (img->mBounds.h > tempHeight) diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp index a92af93bf..202ab0675 100644 --- a/src/resources/dye.cpp +++ b/src/resources/dye.cpp @@ -52,7 +52,7 @@ DyePalette::DyePalette(const std::string &description, const int8_t blockSize) }; for (int i = 0, colorIdx = 0; i < blockSize && colorIdx < 4; - i +=2, colorIdx ++) + i += 2, colorIdx ++) { color.value[colorIdx] = static_cast<unsigned char>(( hexDecode(description[pos + i]) << 4) diff --git a/src/resources/emotedb.cpp b/src/resources/emotedb.cpp index d352e79c3..7e923c034 100644 --- a/src/resources/emotedb.cpp +++ b/src/resources/emotedb.cpp @@ -91,8 +91,8 @@ void EmoteDB::load() { EmoteSprite *const currentSprite = new EmoteSprite; std::string file = paths.getStringValue("sprites") - + std::string(reinterpret_cast<const char*>( - spriteNode->xmlChildrenNode->content)); + .append(std::string(reinterpret_cast<const char*>( + spriteNode->xmlChildrenNode->content))); currentSprite->sprite = AnimatedSprite::load(file, XML::getProperty(spriteNode, "variant", 0)); currentSprite->name = XML::langProperty( @@ -147,8 +147,8 @@ void EmoteDB::load() { EmoteSprite *const currentSprite = new EmoteSprite; std::string file = paths.getStringValue("sprites") - + std::string(reinterpret_cast<const char*>( - spriteNode->xmlChildrenNode->content)); + .append(std::string(reinterpret_cast<const char*>( + spriteNode->xmlChildrenNode->content))); currentSprite->sprite = AnimatedSprite::load(file, XML::getProperty(spriteNode, "variant", 0)); currentSprite->name = XML::langProperty( diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 5fd0da97b..befcd621e 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -323,8 +323,8 @@ void ItemDB::load() if (!value) continue; if (!effect.empty()) - effect += " / "; - effect += strprintf(gettext(fields[i][1]), value); + effect.append(" / "); + effect.append(strprintf(gettext(fields[i][1]), value)); } FOR_EACH (std::vector<Stat>::const_iterator, it, extraStats) { @@ -332,13 +332,13 @@ void ItemDB::load() if (!value) continue; if (!effect.empty()) - effect += " / "; - effect += strprintf(it->format.c_str(), value); + effect.append(" / "); + effect.append(strprintf(it->format.c_str(), value)); } std::string temp = XML::langProperty(node, "effect", ""); if (!effect.empty() && !temp.empty()) - effect += " / "; - effect += temp; + effect.append(" / "); + effect.append(temp); itemInfo->setEffect(effect); for_each_xml_child_node(itemChild, node) diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp index 8033ada7b..04be2fc6f 100644 --- a/src/resources/iteminfo.cpp +++ b/src/resources/iteminfo.cpp @@ -107,7 +107,7 @@ void ItemInfo::setAttackAction(std::string attackAction) void ItemInfo::addSound(const EquipmentSoundEvent event, const std::string &filename) { - mSounds[event].push_back(paths.getStringValue("sfx") + filename); + mSounds[event].push_back(paths.getStringValue("sfx").append(filename)); } const std::string &ItemInfo::getSound(const EquipmentSoundEvent event) const diff --git a/src/resources/mapdb.cpp b/src/resources/mapdb.cpp index 9c0cdce55..0efc07bf6 100644 --- a/src/resources/mapdb.cpp +++ b/src/resources/mapdb.cpp @@ -54,7 +54,7 @@ void MapDB::load() void MapDB::loadRemap() { XML::Document *doc = new XML::Document( - paths.getStringValue("maps") + "remap.xml"); + paths.getStringValue("maps").append("remap.xml")); const XmlNodePtr root = doc->rootNode(); if (!root) diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index cd0b68163..ec7651745 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -71,7 +71,7 @@ static std::string resolveRelativePath(std::string base, std::string relative) // Re-add trailing slash, if needed if (!base.empty() && base[base.length() - 1] != '/') - base += '/'; + base.append("/"); return base + relative; } @@ -264,7 +264,7 @@ Map *MapReader::readMap(XmlNodePtr node, const std::string &path) const bool showWarps = config.getBoolValue("warpParticle"); const std::string warpPath = paths.getStringValue("particles") - + paths.getStringValue("portalEffectFile"); + .append(paths.getStringValue("portalEffectFile")); if (tilew < 0 || tileh < 0) { @@ -862,6 +862,6 @@ void MapReader::updateMusic(Map *const map) const size_t p = name.rfind("."); if (p != std::string::npos) name = name.substr(0, p); - name += ".ogg"; + name.append(".ogg"); map->setProperty("music", name); } diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index 1d6347d75..7759fdb73 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -80,9 +80,9 @@ ResourceManager::~ResourceManager() { if (iter->second->getRefCount()) { - logger->log("ResourceLeak: " + iter->second->getIdPath() - + " (" + toString(iter->second->getRefCount()) - + ")"); + logger->log(std::string("ResourceLeak: ").append( + iter->second->getIdPath()).append(" (").append( + toString(iter->second->getRefCount())).append(")")); } } ++iter; @@ -237,7 +237,7 @@ void ResourceManager::logResource(const Resource *const res) std::string src = image->getSource(); const int count = image->getRefCount(); if (count) - src += " " + toString(count); + src.append(" ").append(toString(count)); if (image) { logger->log("resource(%s, %u) %s", res->mIdPath.c_str(), @@ -341,8 +341,7 @@ void ResourceManager::searchAndAddArchives(const std::string &path, file = path + (*i); realPath = std::string(PhysFs::getRealDir(file.c_str())); - archive = realPath + dirSep + file; - + archive = std::string(realPath).append(dirSep).append(file); addToSearchPath(archive, append); } } @@ -366,8 +365,7 @@ void ResourceManager::searchAndRemoveArchives(const std::string &path, file = path + (*i); realPath = std::string(PhysFs::getRealDir(file.c_str())); - archive = realPath + dirSep + file; - + archive = std::string(realPath).append(dirSep).append(file); removeFromSearchPath(archive); } } @@ -410,12 +408,13 @@ std::string ResourceManager::getPath(const std::string &file) const // if the file is not in the search path, then its nullptr if (tmp) { - path = std::string(tmp) + dirSeparator + file; + path = std::string(tmp).append(dirSeparator).append(file); } else { // if not found in search path return the default path - path = Client::getPackageDirectory() + dirSeparator + file; + path = std::string(Client::getPackageDirectory()).append( + dirSeparator).append(file); } return path; @@ -878,8 +877,9 @@ void ResourceManager::deleteInstance() { if (res->getRefCount()) { - logger->log("ResourceLeak: " + res->getIdPath() - + " (" + toString(res->getRefCount()) + ")"); + logger->log(std::string("ResourceLeak: ").append( + res->getIdPath()).append(" (").append(toString( + res->getRefCount())).append(")")); } } ++iter; @@ -998,9 +998,7 @@ void ResourceManager::saveTextFile(std::string path, std::string name, if (!mkdir_r(path.c_str())) { std::ofstream file; - std::string fileName = path + "/" + name; - - file.open(fileName.c_str(), std::ios::out); + file.open((path.append("/").append(name)).c_str(), std::ios::out); if (file.is_open()) file << text << std::endl; file.close(); diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp index 4af25c8cf..ff9b71901 100644 --- a/src/resources/spritedef.cpp +++ b/src/resources/spritedef.cpp @@ -87,8 +87,8 @@ SpriteDef *SpriteDef::load(const std::string &animationFile, const int variant) { logger->log("Error, failed to parse %s", animationFile.c_str()); - std::string errorFile = paths.getStringValue("sprites") - + paths.getStringValue("spriteErrorFile"); + std::string errorFile = paths.getStringValue("sprites").append( + paths.getStringValue("spriteErrorFile")); if (animationFile != errorFile) return load(errorFile, 0); else @@ -389,7 +389,7 @@ void SpriteDef::includeSprite(const XmlNodePtr includeNode) if (filename.empty()) return; - filename = paths.getStringValue("sprites") + filename; + filename = paths.getStringValue("sprites").append(filename); if (mProcessedFiles.find(filename) != mProcessedFiles.end()) { diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp index 9c694ece9..4f518f083 100644 --- a/src/resources/wallpaper.cpp +++ b/src/resources/wallpaper.cpp @@ -161,7 +161,7 @@ std::string Wallpaper::getWallpaper(const int width, const int height) // Return the backup file if everything else failed... if (haveBackup) - return std::string(wallpaperPath + wallpaperFile); + return std::string(wallpaperPath).append(wallpaperFile); // Return an empty string if everything else failed return std::string(); diff --git a/src/test/testmain.cpp b/src/test/testmain.cpp index aa3254275..42e4ea9bd 100644 --- a/src/test/testmain.cpp +++ b/src/test/testmain.cpp @@ -93,17 +93,17 @@ int TestMain::exec(const bool testAudio) else soundTest = true; - info += strprintf("%d.%d,%d,%d.", soundTest, softwareTest, - fastOpenGLTest, safeOpenGLTest); + info.append(strprintf("%d.%d,%d,%d.", soundTest, softwareTest, + fastOpenGLTest, safeOpenGLTest)); if (!softwareTest) { int softFpsTest = invokeSoftwareRenderTest("8"); - info += strprintf ("%d", softFpsTest); + info.append(strprintf ("%d", softFpsTest)); if (!softFpsTest) { softFps = readValue2(8); - info += strprintf (",%d", softFps); + info.append(strprintf (",%d", softFps)); if (!softFps) { softwareTest = -1; @@ -112,7 +112,7 @@ int TestMain::exec(const bool testAudio) else { rescaleTest[0] = invokeSoftwareRenderTest("5"); - info += strprintf (",%d", rescaleTest[0]); + info.append(strprintf (",%d", rescaleTest[0])); } } else @@ -120,15 +120,15 @@ int TestMain::exec(const bool testAudio) softwareTest = -1; } } - info += "."; + info.append("."); if (!fastOpenGLTest) { int fastOpenGLFpsTest = invokeFastOpenGLRenderTest("9"); - info += strprintf ("%d", fastOpenGLFpsTest); + info.append(strprintf("%d", fastOpenGLFpsTest)); if (!fastOpenGLFpsTest) { fastOpenGLFps = readValue2(9); - info += strprintf (",%d", fastOpenGLFps); + info.append(strprintf(",%d", fastOpenGLFps)); if (!fastOpenGLFps) { fastOpenGLTest = -1; @@ -137,7 +137,7 @@ int TestMain::exec(const bool testAudio) else { rescaleTest[1] = invokeFastOpenGLRenderTest("6"); - info += strprintf (",%d", rescaleTest[1]); + info.append(strprintf (",%d", rescaleTest[1])); } } else @@ -145,15 +145,15 @@ int TestMain::exec(const bool testAudio) fastOpenGLTest = -1; } } - info += "."; + info.append("."); if (!safeOpenGLTest) { int safeOpenGLFpsTest = invokeSafeOpenGLRenderTest("10"); - info += strprintf ("%d", safeOpenGLFpsTest); + info.append(strprintf("%d", safeOpenGLFpsTest)); if (!safeOpenGLFpsTest) { safeOpenGLFps = readValue2(10); - info += strprintf (",%d", safeOpenGLFps); + info.append(strprintf(",%d", safeOpenGLFps)); if (!safeOpenGLFps) { safeOpenGLTest = -1; @@ -162,7 +162,7 @@ int TestMain::exec(const bool testAudio) else { rescaleTest[2] = invokeSafeOpenGLRenderTest("7"); - info += strprintf (",%d", rescaleTest[2]); + info.append(strprintf(",%d", rescaleTest[2])); } } else @@ -170,7 +170,7 @@ int TestMain::exec(const bool testAudio) safeOpenGLTest = -1; } } - info += "."; + info.append("."); int maxFps = softFps; if (maxFps < fastOpenGLFps) diff --git a/src/utils/paths.cpp b/src/utils/paths.cpp index f97ccafcb..f9c5cc5a8 100644 --- a/src/utils/paths.cpp +++ b/src/utils/paths.cpp @@ -149,9 +149,14 @@ std::string getDesktopDir() char *xdg = getenv("XDG_CONFIG_HOME"); std::string file; if (!xdg) - file = std::string(PhysFs::getUserDir()) + "/.config/user-dirs.dirs"; + { + file = std::string(PhysFs::getUserDir()).append( + "/.config/user-dirs.dirs"); + } else - file = std::string(xdg) + "/user-dirs.dirs"; + { + file = std::string(xdg).append("/user-dirs.dirs"); + } StringVect arr = ResourceManager::loadTextFileLocal(file); FOR_EACH (StringVectCIter, it, arr) @@ -165,13 +170,13 @@ std::string getDesktopDir() replaceAll(str, "$HOME/", PhysFs::getUserDir()); str = getRealPath(str); if (str.empty()) - str = std::string(PhysFs::getUserDir()) + "Desktop"; + str = std::string(PhysFs::getUserDir()).append("Desktop"); return str; } } - return std::string(PhysFs::getUserDir()) + "Desktop"; + return std::string(PhysFs::getUserDir()).append("Desktop"); #else - return std::string(PhysFs::getUserDir()) + "Desktop"; + return std::string(PhysFs::getUserDir()).append("Desktop"); #endif } diff --git a/src/utils/process.cpp b/src/utils/process.cpp index bba018195..b24949cfe 100644 --- a/src/utils/process.cpp +++ b/src/utils/process.cpp @@ -51,9 +51,9 @@ int execFileWait(std::string pathName, std::string name A_UNUSED, memset(&piProcessInfo, 0, sizeof(piProcessInfo)); siStartupInfo.cb = sizeof(siStartupInfo); DWORD ret = -1; - std::string args(pathName + " " + arg1); + std::string args(std::string(pathName).append(" ").append(arg1)); if (!arg2.empty()) - args += " " + arg2; + args.append(" ").append(arg2); if (CreateProcess(pathName.c_str(), (char*)args.c_str(), nullptr, nullptr, false, CREATE_DEFAULT_ERROR_MODE, nullptr, nullptr, &siStartupInfo, @@ -84,9 +84,9 @@ bool execFile(std::string pathName, std::string name A_UNUSED, memset(&siStartupInfo, 0, sizeof(siStartupInfo)); memset(&piProcessInfo, 0, sizeof(piProcessInfo)); siStartupInfo.cb = sizeof(siStartupInfo); - std::string args(pathName + " " + arg1); + std::string args(std::string(pathName).append(" ").append(arg1)); if (!arg2.empty()) - args += " " + arg2; + args.append(" ").append(arg2); bool res = CreateProcess(pathName.c_str(), const_cast<char*>( args.c_str()), nullptr, nullptr, false, diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index d4585a26d..3378ec132 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -494,8 +494,8 @@ std::string combineDye(std::string file, std::string dye) return file; const size_t pos = file.find_last_of("|"); if (pos != std::string::npos) - return file.substr(0, pos) + "|" + dye; - return file + "|" + dye; + return file.substr(0, pos).append("|").append(dye); + return file.append("|").append(dye); } std::string combineDye2(std::string file, std::string dye) @@ -515,9 +515,9 @@ std::string combineDye2(std::string file, std::string dye) it2 = list2.begin(), it1_end = list1.end(), it2_end = list2.end(); it1 != it1_end && it2 != it2_end; ++it1, ++it2) { - str += (*it1) + ":" + (*it2) + ";"; + str.append(*it1).append(":").append(*it2).append(";"); } - return file + "|" + str; + return file.append("|").append(str); } else { @@ -531,7 +531,7 @@ std::string packList(const std::list<std::string> &list) std::string str(""); while (i != list.end()) { - str = str + (*i) + "|"; + str.append(*i).append("|"); ++ i; } if (str.size() > 1) @@ -551,7 +551,7 @@ std::string stringToHexPath(const std::string &str) std::string hex = strprintf("%%%2x/", static_cast<int>(str[0])); for (unsigned f = 1, sz = static_cast<unsigned>(str.size()); f < sz; f ++) - hex += strprintf("%%%2x", static_cast<int>(str[f])); + hex.append(strprintf("%%%2x", static_cast<int>(str[f]))); return hex; } |