Skip to content

Commit

Permalink
docs and rename
Browse files Browse the repository at this point in the history
  • Loading branch information
304NotModified authored and snakefoot committed May 21, 2019
1 parent f65a0ae commit fcb1f8a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/NLog/Internal/CollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ namespace NLog.Internal
{
internal static class CollectionExtensions
{
public static IList<TItem> FilterList<TItem,TState>([NotNull] this IList<TItem> items, TState state, Func<TItem, TState, bool> filter)
/// <summary>
/// Memory optimized filtering
/// </summary>
/// <remarks>Passing state too avoid delegate capture and memory-allocations.</remarks>
[NotNull]
public static IList<TItem> Filter<TItem, TState>([NotNull] this IList<TItem> items, TState state, Func<TItem, TState, bool> filter)
{
var hasIgnoredLogEvents = false;
IList<TItem> filterLogEvents = null;
Expand Down
2 changes: 1 addition & 1 deletion src/NLog/Targets/Wrappers/FilteringTargetWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ protected override void Write(AsyncLogEventInfo logEvent)
/// <inheritdoc/>
protected override void Write(IList<AsyncLogEventInfo> logEvents)
{
var filterLogEvents = logEvents.FilterList(Filter, ShouldLogEvent);
var filterLogEvents = logEvents.Filter(Filter, ShouldLogEvent);
WrappedTarget.WriteAsyncLogEvents(filterLogEvents);
}

Expand Down
2 changes: 1 addition & 1 deletion src/NLog/Targets/Wrappers/PostFilteringTargetWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ protected override void Write(IList<AsyncLogEventInfo> logEvents)
else
{
InternalLogger.Trace("PostFilteringWrapper(Name={0}): Filter to apply: {1}", Name, resultFilter);
var resultBuffer = logEvents.FilterList(resultFilter, ApplyFilter);
var resultBuffer = logEvents.Filter(resultFilter, ApplyFilter);
InternalLogger.Trace("PostFilteringWrapper(Name={0}): After filtering: {1} events.", Name, resultBuffer.Count);
if (resultBuffer.Count > 0)
{
Expand Down

0 comments on commit fcb1f8a

Please sign in to comment.