Optimize LINQ Where().Count()

Proprietary

Replace items.Where(predicate).Count() with items.Count(predicate). Passing the predicate directly to Count avoids an intermediate iterator.

OpenRewrite.Recipes.CSharp.CodeQuality.Linq.OptimizeLinqWhereCount
mod run . --recipe=OpenRewrite.Recipes.CSharp.CodeQuality.Linq.OptimizeLinqWhereCount

Install it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.