-
Notifications
You must be signed in to change notification settings - Fork 253
Improve search validator and in-memory evaluator. #443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good; couple minor questions
|
||
private IEnumerator<TSource>? _enumerator; | ||
|
||
public SpecLikeIterator(IEnumerable<TSource> source, List<SearchExpressionInfo<TSource>> searchExpressions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not switching to primary constructor syntax yet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been hesitant because of the older TFMs. We need to check whether we need any polyfills or not (I assume not).
{ | ||
if (_searchExpressions is null) | ||
{ | ||
_searchExpressions = new(2) { searchExpression }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace magic number 2
with meaningful named constant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This represents the initial capacity. And it can be different for each collection, for example we may choose for Where to be 4, for Search 2, etc. We need to introduce 6-7 constants, and not sure whether that makes it better or worse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to use constants.
Fixes #421
Fixes #422
Fixes #424
SearchValidator
to allocation-free implementation. For larger input collections, the difference is drastic. For 1000 entities, the allocations are reduced from 651.160 bytes to ZERO bytes.SeatchMemoryEvaluator
and decreased allocations (constant allocation size regardless of input). Added custom iterator implementation. For larger input collections, the difference is drastic. For a source of 1000 items, the allocations are reduced from 257.872 bytes to only 56 bytes (the cost of the custom iterator instance).