Skip to content

Commit 2809ade

Browse files
perf: replace SubsString with alternative lookup (#4280)
1 parent b81c533 commit 2809ade

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

TUnit.Core/Discovery/ObjectGraphDiscoverer.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,8 +651,13 @@ private static bool IsDirectProperty(string cacheKey, HashSet<string> hierarchyT
651651
return true; // Malformed key, treat as direct
652652
}
653653

654+
#if NET9_0_OR_GREATER
655+
var declaringTypeName = cacheKey.AsSpan()[..lastDotIndex];
656+
return hierarchyTypes.GetAlternateLookup<ReadOnlySpan<char>>().Contains(declaringTypeName);
657+
#else
654658
var declaringTypeName = cacheKey.Substring(0, lastDotIndex);
655659
return hierarchyTypes.Contains(declaringTypeName);
660+
#endif
656661
}
657662

658663
/// <summary>

0 commit comments

Comments
 (0)