LexBuffer.FromString used to copy a string to an array and then pass it to FromArray via FromChars which copies it again, resulting in wasteful allocations.
While entirely eliminating the copies would require non-trivial rearchitecturing, this PR eliminates one of the two by moving the Array.Copy call from FromArray to FromBytes and FromChars, and by modifying FromString to directly call FromArray.
Also a piece of documentation was updated to remove mentions to the non-public FromArray.
LexBuffer.FromString
used to copy a string to an array and then pass it toFromArray
viaFromChars
which copies it again, resulting in wasteful allocations.While entirely eliminating the copies would require non-trivial rearchitecturing, this PR eliminates one of the two by moving the
Array.Copy
call fromFromArray
toFromBytes
andFromChars
, and by modifyingFromString
to directly callFromArray
.Also a piece of documentation was updated to remove mentions to the non-public
FromArray
.