Closed
Description
The current SearchValidator
implementation is as follows.
public bool IsValid<T>(T entity, ISpecification<T> specification)
{
foreach (var searchGroup in specification.SearchCriterias.GroupBy(x => x.SearchGroup))
{
if (searchGroup.Any(c => c.SelectorFunc(entity).Like(c.SearchTerm)) == false) return false;
}
return true;
}
This looks relatively simple, but there are a lot of hidden allocations. Moreover, the number of allocations is not constant, and it depends on the size of the input collection.
We need allocation-free GroupBy implementation. We may keep the search expressions sorted by search group, and then slice to get the groups.
Metadata
Metadata
Assignees
Labels
No labels