summaryrefslogtreecommitdiff
path: root/src/utils/path.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-02-22 13:02:26 +0100
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-02-22 14:32:45 +0100
commit81e4f170d8ba4ccbcfa1e6c07bd0522dfc3b6e08 (patch)
treee2619b16a5331e5760d94be389d0a3a01427293f /src/utils/path.cpp
parentd047db79f7034e0e75a85a656d18f40716d197b9 (diff)
downloadmana-81e4f170d8ba4ccbcfa1e6c07bd0522dfc3b6e08.tar.gz
mana-81e4f170d8ba4ccbcfa1e6c07bd0522dfc3b6e08.tar.bz2
mana-81e4f170d8ba4ccbcfa1e6c07bd0522dfc3b6e08.tar.xz
mana-81e4f170d8ba4ccbcfa1e6c07bd0522dfc3b6e08.zip
General code cleanups
* Use default member initializers * Use range-based loops * Don't use 'else' after 'return' * Removed some unused includes * Construct empty strings with std::string() instead of "" * Clear strings with .clear() instead of assigning "" * Check whether strings are empty with .empty() instead of comparing to "" * Removed redundant initializations
Diffstat (limited to 'src/utils/path.cpp')
-rw-r--r--src/utils/path.cpp18
1 files changed, 8 insertions, 10 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
{