TeamSirenix / odin-serializer

Fast, robust, powerful and extendible .NET serializer built for Unity
http://www.odininspector.com
Apache License 2.0
1.69k stars 193 forks source link

JsonTextReader performance suggestion - Use Ordinal string comparison instead of InvariantCulture #56

Closed JPerryOddGames closed 8 months ago

JPerryOddGames commented 1 year ago

Hi,

I was able to make some meaningful performance improvements in deserializing large json files by changing JsonTextReader.cs to use the Ordinal string comparer instead of using InvariantCulture. As far as I am aware, this change should not break the code for any device with any culture since the code is already explicitly using InvariantCulture. Given the strings we are checking for are all simple hard-coded strings with English characters and a few symbols ($, {, }, [, ]) there should be no difference in the results of an Ordinal or InvariantCulture equality comparison.

Please advise if there is indeed a case where this could potentially break something

TorVestergaard commented 8 months ago

No, this is a good idea - I've approved your pull request. A little late, but approved nevertheless :)