Convert a condition into an assertion per post-review feedback; NFC intended.

llvm-svn: 346714
This commit is contained in:
Aaron Ballman 2018-11-12 22:32:38 +00:00
parent 98e427ccf2
commit a85ba92cb0
1 changed files with 17 additions and 18 deletions

View File

@ -83,26 +83,25 @@ static std::string fileNameToURI(StringRef Filename) {
} }
auto Iter = sys::path::begin(Filename), End = sys::path::end(Filename); auto Iter = sys::path::begin(Filename), End = sys::path::end(Filename);
if (Iter != End) { assert(Iter != End && "Expected there to be a non-root path component.");
// Add the rest of the path components, encoding any reserved characters; // Add the rest of the path components, encoding any reserved characters;
// we skip past the first path component, as it was handled it above. // we skip past the first path component, as it was handled it above.
std::for_each(++Iter, End, [&Ret](StringRef Component) { std::for_each(++Iter, End, [&Ret](StringRef Component) {
// For reasons unknown to me, we may get a backslash with Windows native // For reasons unknown to me, we may get a backslash with Windows native
// paths for the initial backslash following the drive component, which // paths for the initial backslash following the drive component, which
// we need to ignore as a URI path part. // we need to ignore as a URI path part.
if (Component == "\\") if (Component == "\\")
return; return;
// Add the separator between the previous path part and the one being // Add the separator between the previous path part and the one being
// currently processed. // currently processed.
Ret += "/"; Ret += "/";
// URI encode the part. // URI encode the part.
for (char C : Component) { for (char C : Component) {
Ret += percentEncodeURICharacter(C); Ret += percentEncodeURICharacter(C);
} }
}); });
}
return Ret.str().str(); return Ret.str().str();
} }