Skip to content

Commit a3a70ad

Browse files
committed
Simplify TU.FileRelativeDirectory by using Path.GetDirectoryName.
1 parent 6a1db77 commit a3a70ad

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/AST/TranslationUnit.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,10 @@ public string FileRelativeDirectory
6262
if (fileRelativeDirectory != null)
6363
return fileRelativeDirectory;
6464

65-
if (IncludePath == null)
66-
return string.Empty;
65+
var dir = Path.GetDirectoryName(IncludePath) ?? string.Empty;
66+
fileRelativeDirectory = dir.Replace('\\', '/');
6767

68-
var path = IncludePath.Replace('\\', '/');
69-
var index = path.LastIndexOf('/');
70-
if (index == -1)
71-
return string.Empty;
72-
73-
return fileRelativeDirectory = path.Substring(0, index);
68+
return fileRelativeDirectory;
7469
}
7570
}
7671

0 commit comments

Comments
 (0)