From 3f3fd5bf64c091b167c09ad57eb5f9eb4c06a7f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 11 Oct 2024 11:31:37 +0200 Subject: [PATCH] Remove unnecessary allocation in text rendering (Android) --- android/src/org/ppsspp/ppsspp/TextRenderer.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/android/src/org/ppsspp/ppsspp/TextRenderer.java b/android/src/org/ppsspp/ppsspp/TextRenderer.java index a19f2982e6..a2c962157f 100644 --- a/android/src/org/ppsspp/ppsspp/TextRenderer.java +++ b/android/src/org/ppsspp/ppsspp/TextRenderer.java @@ -38,7 +38,7 @@ public class TextRenderer { private static Point measureLine(String string, double textSize) { int w; - if (string.length() > 0) { + if (!string.isEmpty()) { textPaint.setTextSize((float) textSize); w = (int) textPaint.measureText(string); // Round width up to even already here to avoid annoyances from odd-width 16-bit textures @@ -55,7 +55,7 @@ public class TextRenderer { } private static Point measure(String string, double textSize) { - String lines[] = string.replaceAll("\\r", "").split("\n"); + String [] lines = string.replaceAll("\\r", "").split("\n"); Point total = new Point(); total.x = 0; for (String line : lines) { @@ -95,10 +95,9 @@ public class TextRenderer { String lines[] = string.replaceAll("\\r", "").split("\n"); float y = 1.0f; - Path path = new Path(); - + Path path = null; for (String line : lines) { - if (line.length() > 0) { + if (!line.isEmpty()) { if (highContrastFontsEnabled) { // This is a workaround for avoiding "High Contrast Fonts" screwing up our // single-channel font rendering.