SamboyCoding / Tomlet

Zero-Dependency, model-based TOML De/Serializer for .NET
MIT License
155 stars 29 forks source link

Fix bug of not quoting keys with slashes etc #31

Closed ThatCoolCoder closed 1 year ago

ThatCoolCoder commented 1 year ago

I believe this fixes #30, although I haven't written tests for the new behavior (I couldn't figure out where would be most appropriate) and it probably needs a little bit of looking at.

I'm not sure why it's showing the additions of the IEnumerator stuff since the commit history shows that it was already in the code as of 729f57bb51eb973f7c3f534d56d6c4ace29e2fd7, which was what I forked from.

SamboyCoding commented 1 year ago

This is going to need a little more thought on my part, regexes often aren't the most performant things, and I've managed to avoid them so far.

ThatCoolCoder commented 1 year ago

Ok, that's fair enough - I haven't tested the performance of this but I figured that a regex would have less of a performance impact than some sort of linq-based thing checking each character individually.

SamboyCoding commented 1 year ago

It does vary, for certain kinds of operations, especially on .net 7, linq can be very fast thanks to hardware acceleration (vector instructions). And helper functions like char.IsDigit etc exist. Also, might be able to optimize more if we can use ReadOnlySpan, as that has some further optimizations sometimes. I'll try to take a look this week some time to find the optimal solution - at the very least if we were going with regex I'd want RegexOptions.Compiled or on net7 a source-generated regex.