Skip to content

Commit e307c28

Browse files
authored
Merge pull request #189 from brunomikoski/feature/reduce-gc-allocation
Reduce GC allocations in Matches function
2 parents b77dad0 + 6700808 commit e307c28

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Scripts/Runtime/Core/CollectionItemQuery.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public override string ToString()
3737
[SerializeField]
3838
private QuerySet[] query = Array.Empty<QuerySet>();
3939

40+
private HashSet<LongGuid> targetGuids = new HashSet<LongGuid>(128);
41+
4042
public bool Matches(params T[] targetItems)
4143
{
4244
return Matches(targetItems, out _);
@@ -63,7 +65,7 @@ public override string ToString()
6365

6466
public bool Matches(IEnumerable<T> targetItems, out int resultMatchCount)
6567
{
66-
HashSet<LongGuid> targetGuids = new HashSet<LongGuid>();
68+
targetGuids.Clear();
6769
foreach (T item in targetItems)
6870
{
6971
if (item)

0 commit comments

Comments
 (0)