Skip to content

Reduce allocations in XmlWriterApiTests.TCFullEndElement#112688

Merged
akoeplinger merged 2 commits intodotnet:mainfrom
oroztocil:fix/110090-oom-in-xml-writer-tests
Feb 19, 2025
Merged

Reduce allocations in XmlWriterApiTests.TCFullEndElement#112688
akoeplinger merged 2 commits intodotnet:mainfrom
oroztocil:fix/110090-oom-in-xml-writer-tests

Conversation

@oroztocil
Copy link
Copy Markdown
Member

@oroztocil oroztocil commented Feb 19, 2025

Attempt to improve #110090 without disabling tests.

Copilot AI review requested due to automatic review settings February 19, 2025 11:14
@ghost ghost added the area-System.Xml label Feb 19, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/libraries/System.Private.Xml/tests/Writers/XmlWriterApi/TCFullEndElement.cs:6314

  • The variable name 'UniStr' should be renamed to 'uniStr' for consistency with the rest of the code.
string UniStr = "";

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Feb 19, 2025
@oroztocil oroztocil marked this pull request as draft February 19, 2025 11:14
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-xml
See info in area-owners.md if you want to be subscribed.

for (int i = 0; i < strBase64Len; i++)
{
strBase64 += "A";
strBase64Builder.Append("A");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be new string('A', strBase64Len) instead?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, forgot about this overload.

Copy link
Copy Markdown
Member

@akoeplinger akoeplinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM apart from Egor's suggestion.

Comment on lines +6315 to +6318
int charCount = (int)('\ufffe' - '\ue000');
StringBuilder uniStrBuilder = new StringBuilder(charCount);

for (char ch = '\ue000'; ch < '\ufffe'; ch++)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: extract the chars to make it a bit more readable:

Suggested change
int charCount = (int)('\ufffe' - '\ue000');
StringBuilder uniStrBuilder = new StringBuilder(charCount);
for (char ch = '\ue000'; ch < '\ufffe'; ch++)
char startChar = '\ue000';
char endChar = '\ufffe';
int charCount = (int)(endChar - startChar);
StringBuilder uniStrBuilder = new StringBuilder(charCount);
for (char ch = startChar; ch < endChar; ch++)

@oroztocil oroztocil marked this pull request as ready for review February 19, 2025 15:35
@akoeplinger akoeplinger merged commit 4dde471 into dotnet:main Feb 19, 2025
grendello pushed a commit to grendello/runtime that referenced this pull request Feb 19, 2025
* Reduce allocations in XmlWriterApiTests

* Apply code review improvements
@github-actions github-actions bot locked and limited conversation to collaborators Mar 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Xml community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants