From 1c8316e734fb54fff6efc0ef8c11c72d8702a65d Mon Sep 17 00:00:00 2001 From: Richard Webb Date: Sun, 26 Jul 2026 15:20:43 +0100 Subject: [PATCH] perf(Core): Make 'FuncApp' a struct active pattern Gives a small reduction in the number of allocated Options. Before: | Method | Mean | Error | StdDev | Gen0 | Gen1 | Gen2 | Allocated | |--------------- |---------:|--------:|--------:|-----------:|----------:|----------:|----------:| | LintParsedFile | 470.3 ms | 7.04 ms | 5.88 ms | 14000.0000 | 5000.0000 | 1000.0000 | 229.87 MB | After: | Method | Mean | Error | StdDev | Gen0 | Gen1 | Gen2 | Allocated | |--------------- |---------:|--------:|--------:|-----------:|----------:|----------:|----------:| | LintParsedFile | 467.8 ms | 2.57 ms | 2.00 ms | 14000.0000 | 5000.0000 | 1000.0000 | 228.83 MB | --- src/FSharpLint.Core/Framework/Ast.fs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/FSharpLint.Core/Framework/Ast.fs b/src/FSharpLint.Core/Framework/Ast.fs index fe02616b3..ad0956eaa 100644 --- a/src/FSharpLint.Core/Framework/Ast.fs +++ b/src/FSharpLint.Core/Framework/Ast.fs @@ -65,11 +65,12 @@ module Ast = /// Inlines pipe operators to give a flat function application expression /// e.g. `x |> List.map id` to `List.map id x`. + [] let (|FuncApp|_|) functionApplication = match functionApplication with | AstNode.Expression(SynExpr.App(_, _, _, _, range) as functionApplication) -> - Some(flattenFuncExpr List.Empty functionApplication, range) - | _ -> None + ValueSome(flattenFuncExpr List.Empty functionApplication, range) + | _ -> ValueNone [] type Lambda = { Arguments:SynSimplePats list; Body:SynExpr }