Skip to content

Commit

Permalink
Remove unnecessary allocation in text rendering (Android)
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Oct 11, 2024
1 parent c966067 commit 3f3fd5b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions android/src/org/ppsspp/ppsspp/TextRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static void init(Context ctx) {

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
Expand All @@ -55,7 +55,7 @@ private static Point measureLine(String string, double textSize) {
}

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) {
Expand Down Expand Up @@ -95,10 +95,9 @@ public static int[] renderText(String string, double textSize) {
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.
Expand Down

0 comments on commit 3f3fd5b

Please sign in to comment.