From 8b4982be8c8fb2f5d6a9e759563f2934421db422 Mon Sep 17 00:00:00 2001 From: benney Date: Fri, 6 Feb 2026 18:28:38 +1100 Subject: [PATCH] reduce allocs --- .../PaketConfigFiles/ProjectFile.fs | 84 +++++++++++-------- 1 file changed, 51 insertions(+), 33 deletions(-) diff --git a/src/Paket.Core/PaketConfigFiles/ProjectFile.fs b/src/Paket.Core/PaketConfigFiles/ProjectFile.fs index a2c8d61997..c7fac7430c 100644 --- a/src/Paket.Core/PaketConfigFiles/ProjectFile.fs +++ b/src/Paket.Core/PaketConfigFiles/ProjectFile.fs @@ -1146,45 +1146,63 @@ module ProjectFile = let findInsertSpot() = // nuget inserts properties directly at the top, and targets directly at the end. // our inserts depend on $(TargetFrameworkVersion), which may be set either from another import, or directly in the project file. + + // perf analysis shows this function is called many times and allocates several GB of memory in large projects. + // this function is intentionally written imperatively to reduce memory allocs. let mutable iProp = 0 - while iProp < project.ProjectNode.ChildNodes.Count && String.startsWithIgnoreCase " + | x :: _ -> x.AppendChild (createNodeSet "AutoGenerateBindingRedirects" "true" project) |> ignore | _ -> ()