From 2ed50fbf5a7ce39500fb307dc40c014b96b47c46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 13 Aug 2016 15:23:46 +0200 Subject: [PATCH] Refactoring --- lib/path.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/path.cpp b/lib/path.cpp index e84dcbe06..0b8e5b423 100644 --- a/lib/path.cpp +++ b/lib/path.cpp @@ -60,17 +60,11 @@ std::string Path::fromNativeSeparators(std::string path) std::string Path::simplifyPath(std::string originalPath) { - const bool isUnc = originalPath.size() > 2 && originalPath[0] == '/' && originalPath[1] == '/'; + const bool isUnc = originalPath.compare(0,2,"//") == 0; // Remove ./, .//, ./// etc. at the beginning - while (originalPath.size() > 2 && originalPath[0] == '.' && originalPath[1] == '/') { // remove "./././" - size_t toErase = 2; - for (std::size_t i = 2; i < originalPath.size(); i++) { - if (originalPath[i] == '/') - toErase++; - else - break; - } + while (originalPath.compare(0,2,"./") == 0) { // remove "./././" + size_t toErase = originalPath.find_first_not_of("/",2); originalPath = originalPath.erase(0, toErase); }