Performance issue with text parsing
The bug
Since Minecraft 1.12 (or a bit before), some of the font rendering was remade, and a minor performance issue was introduced.
In the ChatFormatting class:
public static ChatFormatting getByCode(char c) { char lower = Character.toString(c).toLowerCase(Locale.ROOT).charAt(0);
Here, there is a useless conversion from a character to a string, a lowercase string, then a character again. A simple Character.toLowerCase(c) would have been enough.
This issue was even worse before 1.12, where the whole rendered text was being changed to lowercase on each color character, and was causing a ~1% performance drop when rendering a lot of text. Here the impact is minor, but would still be a good improvement to clean it up.
- Fixed
Rigner[Mojang] etanaratsastaja
- 8
- 8
- Plausible
Low
- Platform
- Performance
- Optimization Rendering Text
1.17.1 - 1.20.2
1.17.1 21w37a 21w38a 21w39a 21w40a 21w41a 21w42a 21w43a 21w44a 1.18-pre1 1.18-pre2 1.18-pre3 1.18-pre4 1.18-pre6 1.18-pre7 1.18-pre8 1.18-rc2 1.18-rc3 1.18-rc4 1.18 1.18.1-pre1 1.18.1-rc1 1.18.1-rc2 1.18.1 22w03a 22w06a 1.18.2-pre1 1.18.2-pre2 1.18.2 22w11a 22w12a 22w13a 22w14a 22w15a 22w17a 22w18a 22w19a 1.19-pre3 1.19-pre4 1.19-pre5 1.19-rc1 1.19-rc2 1.19 1.19.1-pre1 1.19.1-pre2 1.19.1-pre4 1.19.1-pre5 1.19.1 1.19.2 22w45a 22w46a 1.19.3-pre2 1.19.3-rc2 1.19.3-rc3 1.19.3 23w05a 23w06a 23w07a 1.19.4-pre1 1.19.4-pre2 1.19.4-pre3 1.19.4-rc1 1.19.4-rc2 1.19.4-rc3 1.19.4 23w13a 23w14a 23w16a 23w17a 23w18a 1.20-pre1 1.20-pre2 1.20-rc1 1.20 1.20.1-rc1 1.20.1 1.20.2- 23w41a
Created Issue:
Performance issue with font parsing
Since Minecraft 1.14 (or 1.13), some of the font rendering was remade, and a minor performance issue was introduced.
In the ChatFormatting class:
public static ChatFormatting getByCode(char c) { char lower = Character.toString(c).toLowerCase(Locale.ROOT).charAt(0);Here, there is a useless convertion from a character to a string, a lowercase string, then a character again. A simple `Character.toLowerCase(c)` would have been enough.
This issue was even worse before 1.12, where the whole rendered text was being changed to lowercase on each color character, and was causing a ~1% performance drop when rendering a lot of text. Here the impact is minor, but would still be a good improvement to clean it up.
Since Minecraft 1.1
4(or1.13), some of the font rendering was remade, and a minor performance issue was introduced.In the ChatFormatting class:
public static ChatFormatting getByCode(char c) { char lower = Character.toString(c).toLowerCase(Locale.ROOT).charAt(0);Here, there is a useless convertion from a character to a string, a lowercase string, then a character again. A simple `Character.toLowerCase(c)` would have been enough.
This issue was even worse before 1.12, where the whole rendered text was being changed to lowercase on each color character, and was causing a ~1% performance drop when rendering a lot of text. Here the impact is minor, but would still be a good improvement to clean it up.
Since Minecraft 1.12 (or a bit before), some of the font rendering was remade, and a minor performance issue was introduced.
In the ChatFormatting class:
public static ChatFormatting getByCode(char c) { char lower = Character.toString(c).toLowerCase(Locale.ROOT).charAt(0);Here, there is a useless convertion from a character to a string, a lowercase string, then a character again. A simple `Character.toLowerCase(c)` would have been enough.
This issue was even worse before 1.12, where the whole rendered text was being changed to lowercase on each color character, and was causing a ~1% performance drop when rendering a lot of text. Here the impact is minor, but would still be a good improvement to clean it up.
Performance issue withfont parsingPerformance issue with text parsing
Since Minecraft 1.12 (or a bit before), some of the font rendering was remade, and a minor performance issue was introduced.
In the ChatFormatting class:
public static ChatFormatting getByCode(char c) { char lower = Character.toString(c).toLowerCase(Locale.ROOT).charAt(0);Here, there is a useless convertion from a character to a string, a lowercase string, then a character again. A simple `Character.toLowerCase(c)` would have been enough.
This issue was even worse before 1.12, where the whole rendered text was being changed to lowercase on each color character, and was causing a ~1% performance drop when rendering a lot of text. Here the impact is minor, but would still be a good improvement to clean it up.
The bug
Since Minecraft 1.12 (or a bit before), some of the font rendering was remade, and a minor performance issue was introduced.
In the ChatFormatting class:
public static ChatFormatting getByCode(char c) { char lower = Character.toString(c).toLowerCase(Locale.ROOT).charAt(0);Here, there is a useless conversion from a character to a string, a lowercase string, then a character again. A simple Character.toLowerCase(c) would have been enough.
This issue was even worse before 1.12, where the whole rendered text was being changed to lowercase on each color character, and was causing a ~1% performance drop when rendering a lot of text. Here the impact is minor, but would still be a good improvement to clean it up.
You also have a very important security leak on this Jira. Anyone can set values that they shouldn't be able to, like Mojang Priority or Category, by just enabling the HTML elements in the edit form and sending it.
Still an issue in 21w37a.
Still an issue in 21w38a.
Still an issue in 21w39a.
Still an issue in 21w40a.
Still an issue in 21w41a.
Still an issue in 21w42a.
Still an issue in 21w43a.
Still an issue in 21w44a.
Still an issue in 1.18 Pre-release 1.
– I am a bot. This action was performed automatically! If you think it was incorrect, please notify us on Discord or Reddit
Is it okay to make this issue public or does it contain any sensitive information?
Hey, I originally made this private because it was showing Minecraft original codebase. As long as it's ok for you, you can make it public
Can you show a profile the data that supports this assessment? Thanks.
This issue is still present in the game as of 23w05a.
It's a very small optimisation, just to get a few nanoseconds, but that's still an improvement when a lot of colored text is being rendered. It's not much, but for the time it takes to fix it (less than 5 minutes), that's definitely worth it. Also would make the code more readable and clear for the future.
> Can you show a profile the data that supports this assessment? Thanks.
I have made a small benchmark with 100 million iterations and 5 cycles of iterations, the result I got was:
code: