fsprojects / FsLexYacc

Lexer and parser generators for F#
http://fsprojects.github.io/FsLexYacc/
MIT License
207 stars 69 forks source link

Avoid copying a string twice in `LexBuffer.FromString`. #150

Closed teo-tsirpanis closed 3 years ago

teo-tsirpanis commented 3 years ago

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.

sergey-tihon commented 3 years ago

@teo-tsirpanis this change released in v11.0.0-beta1. Feel free to test that it works for you.