Skip to content

Commit

Permalink
perf: Return early in getTextScale() if text is empty or starts with …
Browse files Browse the repository at this point in the history
…letter (#3426)

Not sure why, but `setText()` seems to be called with an empty string
very often - for this case it's nice if getTextScale() returns early.

If the text starts with a letter, we can also return early.
  • Loading branch information
Hocuri authored Nov 13, 2024
1 parent 9f3eeb3 commit cc419a9
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void setText(@Nullable CharSequence text, BufferType type) {


private float getTextScale(String text) {
if (text.length() > 21) {
if (text.length() > 21 || text.isEmpty() || Character.isLetter(text.charAt(0))) {
return 1;
}
int emojiCount = countGraphemes(text, 8);
Expand Down

0 comments on commit cc419a9

Please sign in to comment.