Przeglądaj źródła

common/file_util: Remove unnecessary return at end of void StripTailDirSlashes()

While we're at it, also invert the conditional into a guard clause.
Lioncash 7 lat temu
rodzic
commit
e7ab0e9127
1 zmienionych plików z 8 dodań i 6 usunięć
  1. 8 6
      src/common/file_util.cpp

+ 8 - 6
src/common/file_util.cpp

@@ -78,13 +78,15 @@ namespace FileUtil {
 // Remove any ending forward slashes from directory paths
 // Modifies argument.
 static void StripTailDirSlashes(std::string& fname) {
-    if (fname.length() > 1) {
-        std::size_t i = fname.length();
-        while (i > 0 && fname[i - 1] == DIR_SEP_CHR)
-            --i;
-        fname.resize(i);
+    if (fname.length() <= 1) {
+        return;
+    }
+
+    std::size_t i = fname.length();
+    while (i > 0 && fname[i - 1] == DIR_SEP_CHR) {
+        --i;
     }
-    return;
+    fname.resize(i);
 }
 
 bool Exists(const std::string& filename) {