[PATCH] D111730: [Support] [Path] Use std::replace instead of an explicit comparison loop. NFC.
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 13 08:31:41 PDT 2021
mstorsjo created this revision.
mstorsjo added reviewers: thakis, rnk.
Herald added subscribers: dexonsmith, hiraditya.
mstorsjo requested review of this revision.
Herald added a project: LLVM.
After 8fc7a907b93a8e9eef96e872f8f926db3ebfe9b6 <https://reviews.llvm.org/rG8fc7a907b93a8e9eef96e872f8f926db3ebfe9b6>, this loop does
the same as a plain `std::replace`.
Also clarify the comment about what this function does.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D111730
Files:
llvm/include/llvm/Support/Path.h
llvm/lib/Support/Path.cpp
Index: llvm/lib/Support/Path.cpp
===================================================================
--- llvm/lib/Support/Path.cpp
+++ llvm/lib/Support/Path.cpp
@@ -557,9 +557,7 @@
Path = PathHome;
}
} else {
- for (auto PI = Path.begin(), PE = Path.end(); PI < PE; ++PI)
- if (*PI == '\\')
- *PI = '/';
+ std::replace(Path.begin(), Path.end(), '\\', '/');
}
}
Index: llvm/include/llvm/Support/Path.h
===================================================================
--- llvm/include/llvm/Support/Path.h
+++ llvm/include/llvm/Support/Path.h
@@ -212,7 +212,7 @@
/// Convert path to the native form. This is used to give paths to users and
/// operating system calls in the platform's normal way. For example, on Windows
-/// all '/' are converted to '\'.
+/// all '/' are converted to '\'. On Unix, it converts all '\' to '/'.
///
/// @param path A path that is transformed to native format.
/// @param result Holds the result of the transformation.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111730.379411.patch
Type: text/x-patch
Size: 997 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211013/e2f63d2e/attachment.bin>
More information about the llvm-commits
mailing list