New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove unneeded allocations parsing assets file #4483
Conversation
If you name your branch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found another code path where a similar fix can be applied. The fix is to replace the line no:712
with return new List<IAssetsLogMessage>(0);
and replace line no: 715
with var items = new List<IAssetsLogMessage>(json.Count);
NuGet.Client/src/NuGet.Core/NuGet.ProjectModel/LockFile/LockFileFormat.cs
Lines 708 to 725 in b76bf48
internal static IList<IAssetsLogMessage> ReadLogMessageArray(JArray json, string projectPath) | |
{ | |
if (json == null) | |
{ | |
return new List<IAssetsLogMessage>(); | |
} | |
var items = new List<IAssetsLogMessage>(); | |
foreach (var child in json) | |
{ | |
var logMessage = ReadLogMessage(child as JObject, projectPath); | |
if (logMessage != null) | |
{ | |
items.Add(logMessage); | |
} | |
} | |
return items; | |
} |
I restarted the failing test job |
These List<T> where unnecessarily being resized despite being aware of how many items are being added.
4657f0a
to
092e513
Compare
@kartheekp-ms I fixed that one too. |
Bug
Fixes: NuGet/Home#11648
Regression? Last working version:
Description
Remove unneeded allocations parsing assets file
PR Checklist
PR has a meaningful title
PR has a linked issue.
Described changes
Tests
Documentation