SHsuperCM / CITResewn

Fabric implementation of mcpatcher's cit
MIT License
154 stars 76 forks source link

Add check for a JSON element before attempting to match a string #315

Closed nea89o closed 10 months ago

nea89o commented 10 months ago

This has previously caused massive performance issues, especially in packs that frequently match non text elements. (see https://spark.lucko.me/R6fJJ3zXOJ and the massive amounts of the trace that is taken up by JsonSyntaxExceptions and MalformedJsonExceptions that trace back to this line)

This patch first does a sanity check on the text element to see if it ever could be a JSON element.

SHsuperCM commented 10 months ago

Very similar to #311 and has some of the same issues such as:

Also a note about code style which is that var is used unnecessarily which is far from the code style used within the project, if it's just a String, let it be a String.

As I said in #311, I appreciate you bringing this to my attention and I will be looking into optimizing this section.