Cysharp/ZString

Can u change your current stringbuilder.tostring to ------> (see in the description box)

CodingMadness opened this issue · 1 comments

public override string ToString()
      {
         return string.Create(buffer.Length, buffer,
            (x, y) =>
            {
               y.AsSpan(0, x.Length).CopyTo(x);
            }
         );
      }

i have read several times that the new string.Create(..) is much faster since it does only 1 internal allocation when u know the exact size of the buffer u wanna create a string of, and you do ! and there are ofc also no extra delegate allocation in this when u avouid using the 2.parameter "state" and use the (x, y) only! which I do in this case.

This is faster for APIs that need to write to Span.
In the case of ZString, the result will be the same since there is a written Buffer.