From d4febba47388979b26cd4680cb8a6f20e548e399 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 26 Feb 2013 01:40:00 +0300 Subject: Improve string usage in other files. --- src/utils/paths.cpp | 15 ++++++++++----- src/utils/process.cpp | 8 ++++---- src/utils/stringutils.cpp | 12 ++++++------ 3 files changed, 20 insertions(+), 15 deletions(-) (limited to 'src/utils') 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( 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 &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(str[0])); for (unsigned f = 1, sz = static_cast(str.size()); f < sz; f ++) - hex += strprintf("%%%2x", static_cast(str[f])); + hex.append(strprintf("%%%2x", static_cast(str[f]))); return hex; } -- cgit v1.2.3-70-g09d2