Change string.Repeat to use SpanAction string.Create#72
Change string.Repeat to use SpanAction string.Create#72Unordinal wants to merge 1 commit intoardalis:mainfrom
Conversation
|
In your PR does it make sense to just replace |
I did replace the current Or do you mean replacing the benchmark of the current version ( Edit: Ah, or maybe you meant having both the current version and the one from my PR? They both result in the same thing, so I don't think it would make sense to keep both. |
|
Oh if you did then never mind - I was just looking at it in the browser and saw there were 2 public methods. |
Ah, I actually had to double-check myself when I saw that as well, hah. The new |
This change minimizes
string.Repeatallocations via theSpanActionstring.Createoverload and gives a slight speed boost.This implementation of the string repeat extension uses the
string.Createoverload that takes aSpanActionto write directly into the resulting string buffer instead of allocating a new string. This shaves off a bit of time and reduces the allocations by half due to not having to create a temporary buffer.