diff options
author | Marius Ungureanu <teromario@yahoo.com> | 2016-09-23 03:55:14 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-23 03:55:14 +0300 |
commit | d85ec9d694ff893090b479ceb624efb0064d999a (patch) | |
tree | c2423ef9ce87efb34160d89e37f4e77226236d40 /main | |
parent | ae9ab201506b7b20a474d8355cd8abb4fadef194 (diff) | |
parent | 37af113fcf3571814e974467e7be80283553f685 (diff) |
Merge pull request #1635 from mono/optimize-filepath
[Core] FilePath no longer creates extra strings on IsChildPathof.
Diffstat (limited to 'main')
-rw-r--r-- | main/src/core/MonoDevelop.Core/MonoDevelop.Core/FilePath.cs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FilePath.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FilePath.cs index 0f8f88efd2..f5a55cf727 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FilePath.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FilePath.cs @@ -172,11 +172,15 @@ namespace MonoDevelop.Core }
public bool IsChildPathOf (FilePath basePath)
- {
- if (basePath.fileName [basePath.fileName.Length - 1] != Path.DirectorySeparatorChar)
- return fileName.StartsWith (basePath.fileName + Path.DirectorySeparatorChar, PathComparison); - else
- return fileName.StartsWith (basePath.fileName, PathComparison); + { + bool startsWith = fileName.StartsWith (basePath.fileName, PathComparison); + if (startsWith && basePath.fileName [basePath.fileName.Length - 1] != Path.DirectorySeparatorChar) {
+ // If the last character isn't a path separator character, check whether the string we're searching in
+ // has more characters than the string we're looking for then check the character. + if (fileName.Length > basePath.fileName.Length) + startsWith &= fileName [basePath.fileName.Length] == Path.DirectorySeparatorChar; + } + return startsWith;
}
public FilePath ChangeExtension (string ext)
|