Refactor ImageTagHandler.cs
#165
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First of all, I want to thank and congratulate you for this mod ... it's insanely helpful!
I mainly did three things here:
ImageTagHandler: Honestly, I'm not sure why I initially decided to do this refactor, but I can say I wanted to help with code maintenance and performance since this is a mod I always use. As for the comments I usually add for myself, feel free to keep or remove them—I personally find them very helpful for my future self or anyone else who comes across the code.RecurrentErrorLoggeras part of the refactor: This should allow errors to be logged in places that are called repeatedly (like the tag handler or any draw method, for instance).UITextSnippetto improve performance: The wayChatManager.ParseMessagewas being called caused snippets to be instantiated way too many times per second. From my analysis, eachImageTagSnippetwas being instantiated about 500 times per second, and with this cache change, it's down to ~300 per second. It's not perfect, but it seems to be working as intended.Feel free to accept or reject any of the changes, and thanks again for your work on this mod!