Skip to content

New Filter Operators: #758#941

Merged
JakenVeina merged 3 commits intomainfrom
feature/filter-with-state-stream
Dec 27, 2024
Merged

New Filter Operators: #758#941
JakenVeina merged 3 commits intomainfrom
feature/filter-with-state-stream

Conversation

@JakenVeina
Copy link
Copy Markdown
Collaborator

Added new Filter operators that utilize a predicate state stream, to help avoid unneccessary allocations of a new filter predicate delegate, every time the consumer desires to change filtering logic.

public static IObservable<IChangeSet<TObject, TKey>> Filter<TObject, TKey, TState>(
        this    IObservable<IChangeSet<TObject, TKey>>  source,
                IObservable<TState>                     predicateState,
                Func<TState, TObject, bool>             predicate,
                bool                                    suppressEmptyChangeSets = true)
    where TObject : notnull
    where TKey : notnull
Method Mean Error StdDev Ratio Allocated Alloc Ratio
RandomizedEditsAndStateChanges 345.4 ms 6.90 ms 17.80 ms 1.00 8.57 MB 1.00
public static IObservable<IChangeSet<T>> Filter<T, TState>(
        this    IObservable<IChangeSet<T>>  source,
                IObservable<TState>         predicateState,
                Func<TState, T, bool>       predicate,
                ListFilterPolicy            filterPolicy            = ListFilterPolicy.CalculateDiff,
                bool                        suppressEmptyChangeSets = true)
    where T : notnull
Method FilterPolicy Mean Error StdDev Ratio Allocated Alloc Ratio
RandomizedEditsAndStateChanges ClearAndReplace 26.37 ms 0.510 ms 0.663 ms 1.00 1.88 MB 1.00
RandomizedEditsAndStateChanges CalculateDiff 43.68 ms 0.868 ms 1.673 ms 1.00 3.63 MB 1.00

…help avoid unneccessary allocations of a new filter predicate delegate, every time the consumer desires to change filtering logic.
@JakenVeina JakenVeina merged commit 37ffe9d into main Dec 27, 2024
@JakenVeina JakenVeina deleted the feature/filter-with-state-stream branch December 27, 2024 05:56
@github-actions
Copy link
Copy Markdown

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: New higher-performance Filter() operators

2 participants