Skip to content

Commit 8861508

Browse files
committed
[GameState] Optimize IsDiskPartitionExist method
about 50% faster on checking Hi3 Cache (1.2ms -> 550ms) by not copying and casting the results twice
1 parent 1395543 commit 8861508

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

CollapseLauncher/Classes/GameManagement/Versioning/GameVersionBase.GameState.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -263,15 +263,9 @@ protected virtual bool IsDiskPartitionExist(string? path)
263263
{
264264
try
265265
{
266-
ReadOnlySpan<char> pathRoot = Path.GetPathRoot(path);
267-
if (pathRoot.IsEmpty)
268-
{
269-
return false;
270-
}
271-
272-
string pathRootStr = pathRoot.ToString();
273-
// Return from Directory.Exists() since the IsReady property use the same method.
274-
return Directory.Exists(pathRootStr);
266+
var pathRoot = Path.GetPathRoot(path);
267+
return !string.IsNullOrEmpty(pathRoot) && Directory.Exists(pathRoot);
268+
// Return from Directory.Exists() since the IsReady property use the same method.
275269
}
276270
catch (Exception)
277271
{

0 commit comments

Comments
 (0)