Skip to content

Conversation

@gfoidl
Copy link
Member

@gfoidl gfoidl commented May 28, 2024

Basically it's

-if (textMaxCharCount < 256)
+if (textMaxCharCount <= 256)

to use stack-alloc when the count is the same as the stack threshold, and

-utf16Text = utf16TextArray.AsSpan(0, textMaxCharCount);
+utf16Text = utf16TextArray;

to avoid the slicing as the buffer in the to be called methods can be larger than needed thus to avoid some unnecessary work.

@ghost ghost added the area-System.Numerics label May 28, 2024
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label May 28, 2024
@dotnet-policy-service
Copy link
Contributor

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

Copy link
Member

@tannergooding tannergooding left a comment

Choose a reason for hiding this comment

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

LGTM.

Just noting that this code doesn't really matter, it's a fallback to ensure that we don't get a method not found exception and should never be called for typical user-types.

That is, anyone implementing an interface should typically be providing their own implementation and ignoring the DIM's existence, especially if performance is a consideration.

@tannergooding tannergooding merged commit db0eb5d into dotnet:main Jun 5, 2024
@gfoidl gfoidl deleted the buffer-rent-tweaks branch June 5, 2024 08:30
@github-actions github-actions bot locked and limited conversation to collaborators Jul 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Numerics 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