aaubry / YamlDotNet

YamlDotNet is a .NET library for YAML
MIT License
2.54k stars 477 forks source link

Use a span to reduce string allocations #825

Closed rbnswartz closed 1 year ago

rbnswartz commented 1 year ago

On versions that support it we can use Span to ease GC pressure by not having to allocate a temporary string from substring, instead we can just get a readonly span of what we want and send that to the string builder

rbnswartz commented 1 year ago

There wasn't anything in the style guide about # directives so if you would like me to adjust the indentation on them let me know.

EdwardCooke commented 1 year ago

Thanks for this. I’ll review shortly, I’m thinking it may be beneficial to somehow break this out so it’s reusable to not litter the code with compiler directives. We do a lot like this throughout the library and it would probably help.

aaubry commented 1 year ago

This feature has been released in version 13.2.0.