Commit 7a8ea60b authored by Brad King's avatar Brad King Committed by Kitware Robot

Merge topic 'case-path-rel-perf'

a3caaeec SystemTools: faster relative path codepath
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !91
parents 2ad561e7 a3caaeec
......@@ -3344,15 +3344,20 @@ std::string SystemTools::RelativePath(const std::string& local,
static std::string GetCasePathName(std::string const& pathIn)
{
std::string casePath;
std::vector<std::string> path_components;
SystemTools::SplitPath(pathIn, path_components);
if (path_components[0].empty()) // First component always exists.
{
// Relative paths cannot be converted.
// First check if the file is relative. We don't fix relative paths since the
// real case depends on the root directory and the given path fragment may
// have meaning elsewhere in the project.
if (!SystemTools::FileIsFullPath(pathIn)) {
// This looks unnecessary, but it allows for the return value optimization
// since all return paths return the same local variable.
casePath = pathIn;
return casePath;
}
std::vector<std::string> path_components;
SystemTools::SplitPath(pathIn, path_components);
// Start with root component.
std::vector<std::string>::size_type idx = 0;
casePath = path_components[idx++];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment