Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Use string.Create instead of StringBuilder in BitVector32.ToString #30528

Merged
merged 1 commit into from Jun 20, 2018

Conversation

stephentoub
Copy link
Member

Removes the StringBuilder and underlying char[] allocation, and just writes directly into the resulting string.

cc: @safern, @ianhays

Removes the StringBuilder and underlying char[] allocation, and just writes directly into the resulting string.
Copy link
Member

@safern safern left a comment

Choose a reason for hiding this comment

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

Nice! Thanks @stephentoub

@stephentoub stephentoub merged commit f3eec79 into dotnet:master Jun 20, 2018
@stephentoub stephentoub deleted the bitvecttostring branch June 20, 2018 00:20
}
else
ReadOnlySpan<char> prefix = "BitVector32{";
prefix.CopyTo(dst);
Copy link
Member

Choose a reason for hiding this comment

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

Should we add an API to span to insert a ReadOnlySpan?

So that instead of doing:

ReadOnlySpan<char> prefix = "BitVector32{"
prefix.CopyTo(dst);

We just call that API like:

dst.Insert(index: 0, readOnlySpan<char>: "BitVector32{");

picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…otnet/corefx#30528)

Removes the StringBuilder and underlying char[] allocation, and just writes directly into the resulting string.

Commit migrated from dotnet/corefx@f3eec79
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants