minicraft-plus-revived
minicraft-plus-revived copied to clipboard
Update some code handling strings where performance issues occur
This improves a little performance issue. Here, Double#parseDouble
is used to validate whether the input is double. It can be problematic as it throws exceptions when the input is invalid while the input is invalid most of the time. It is known that creation of exceptions are expensive due to the creations of stack traces. This pull request changes it to regex matching, though I doubt there would be an entry of number with localization enabled.
1~5% performance improvement is already significant when CPU time can be reduced. This kind of use cases (using methods with exceptions) will be carefully assessed when it can affect performance, in the code optimization task in the near future.
- When mainly browsing world:
- When browsing around menus and displays full of text:
- When testing #686 (mainly with inventory menus):
- When browsing around menus and displays full of text with this pull request: