[Support] [Path] Use std::replace instead of an explicit comparison loop. NFC.

After 8fc7a907b9, this loop does
the same as a plain `std::replace`.

Also clarify the comment about what this function does.

Differential Revision: https://reviews.llvm.org/D111730
This commit is contained in:
Martin Storsjö 2021-10-04 16:48:07 +03:00
parent d9b9a7f428
commit 2a4b1539e9
2 changed files with 2 additions and 4 deletions

View File

@ -212,7 +212,7 @@ void append(SmallVectorImpl<char> &path, const_iterator begin,
/// 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.

View File

@ -557,9 +557,7 @@ void native(SmallVectorImpl<char> &Path, Style style) {
Path = PathHome;
}
} else {
for (auto PI = Path.begin(), PE = Path.end(); PI < PE; ++PI)
if (*PI == '\\')
*PI = '/';
std::replace(Path.begin(), Path.end(), '\\', '/');
}
}