Skip to content

Commit

Permalink
+ use plain code instead of linq
Browse files Browse the repository at this point in the history
  • Loading branch information
andreakarasho committed Sep 11, 2024
1 parent 3c7231b commit 2e2d972
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions src/Match.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,38 @@ public static int Validate(IComparer<ulong> comparer, EcsID[] ids, ReadOnlySpan<
if (terms.IsEmpty)
return -1;

foreach (var term in terms)
foreach (ref readonly var term in terms)
{
switch (term.Op)
{
case TermOp.DataAccess:
case TermOp.With:
if (ids.All(id => ComponentComparer.CompareTerms(null, id, term.Id) != 0))
var all = true;
foreach (var id in ids)
{
if (ComponentComparer.CompareTerms(null, id, term.Id) == 0)

Check warning on line 19 in src/Match.cs

View workflow job for this annotation

GitHub Actions / build

Cannot convert null literal to non-nullable reference type.

Check warning on line 19 in src/Match.cs

View workflow job for this annotation

GitHub Actions / build

Cannot convert null literal to non-nullable reference type.
{
all = false;
break;
}
}

if (all)
{
return 1; // Required ID not found
}

break;
case TermOp.Without:
if (ids.Any(id => ComponentComparer.CompareTerms(null, id, term.Id) == 0))
{
return -1; // Forbidden ID found
}
break;
foreach (var id in ids)
{
if (ComponentComparer.CompareTerms(null, id, term.Id) == 0)

Check warning on line 35 in src/Match.cs

View workflow job for this annotation

GitHub Actions / build

Cannot convert null literal to non-nullable reference type.
{
return -1; // Forbidden ID found
}
}

break;
case TermOp.Optional:
// Do nothing, as presence or absence is acceptable
break;
Expand Down

0 comments on commit 2e2d972

Please sign in to comment.