diff options
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/path.cpp | 18 | ||||
-rw-r--r-- | src/utils/sha256.cpp | 2 | ||||
-rw-r--r-- | src/utils/stringutils.cpp | 8 |
3 files changed, 13 insertions, 15 deletions
diff --git a/src/utils/path.cpp b/src/utils/path.cpp index 95db40d3..c78f0fd7 100644 --- a/src/utils/path.cpp +++ b/src/utils/path.cpp @@ -75,10 +75,8 @@ namespace utils { return path1 + path2; } - else - { - return path1 + "/" + path2; - } + + return path1 + "/" + path2; } /** @@ -86,14 +84,14 @@ namespace utils */ std::string cleanPath(const std::string &path) { - size_t prev, cur; - std::string part, result; + std::string part; + std::string result; std::vector<std::string> pathStack; - prev = 0; + size_t prev = 0; while (true) { - cur = path.find_first_of("/\\", prev); + size_t cur = path.find_first_of("/\\", prev); if (cur == std::string::npos) { // FIXME add everything from prev to the end @@ -114,12 +112,12 @@ namespace utils { // do nothing } - else if (part == "") + else if (part.empty()) { if (pathStack.empty() && cur == 0) { // handle first empty match before the root slash - pathStack.push_back(std::string()); + pathStack.emplace_back(); } else { diff --git a/src/utils/sha256.cpp b/src/utils/sha256.cpp index a18e5f18..0e44af7a 100644 --- a/src/utils/sha256.cpp +++ b/src/utils/sha256.cpp @@ -264,7 +264,7 @@ std::string SHA256Hash(const char *src, int len) SHA256Final(&ctx, bytehash); // Convert it to hex const char* hxc = "0123456789abcdef"; - std::string hash = ""; + std::string hash; for (unsigned char i : bytehash) { hash += hxc[i / 16]; diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index 57138005..32fc3b0c 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -187,8 +187,8 @@ bool getBoolFromString(const std::string &text, bool def) return true; if (a == "false" || a == "0" || a == "off" || a == "no" || a == "n") return false; - else - return def; + + return def; } std::string autocomplete(const std::vector<std::string> &candidates, @@ -196,7 +196,7 @@ std::string autocomplete(const std::vector<std::string> &candidates, { auto i = candidates.begin(); toLower(base); - std::string newName(""); + std::string newName; while (i != candidates.end()) { @@ -208,7 +208,7 @@ std::string autocomplete(const std::vector<std::string> &candidates, std::string::size_type pos = name.find(base, 0); if (pos == 0) { - if (newName != "") + if (!newName.empty()) { toLower(newName); newName = findSameSubstring(name, newName); |