From 45c17d35da996447f846ab6c77bb6cc96c7e7d81 Mon Sep 17 00:00:00 2001 From: Myrd Date: Tue, 30 Dec 2014 22:32:52 +0000 Subject: [PATCH] ArrayList of Floats -> float[] to avoid a bunch of temp allocations in frequently called code. --- forge-gui-mobile/src/forge/card/CardImageRenderer.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/forge-gui-mobile/src/forge/card/CardImageRenderer.java b/forge-gui-mobile/src/forge/card/CardImageRenderer.java index 839d25b150f..d520194e947 100644 --- a/forge-gui-mobile/src/forge/card/CardImageRenderer.java +++ b/forge-gui-mobile/src/forge/card/CardImageRenderer.java @@ -299,10 +299,10 @@ public class CardImageRenderer { float padding = Math.round(PT_FONT.getCapHeight() / 4); float totalPieceWidth = -padding; - List pieceWidths = new ArrayList(); - for (String piece : pieces) { - float pieceWidth = PT_FONT.getBounds(piece).width + padding; - pieceWidths.add(pieceWidth); + float[] pieceWidths = new float[pieces.size()]; + for (int i = 0; i < pieces.size(); i++) { + float pieceWidth = PT_FONT.getBounds(pieces.get(i)).width + padding; + pieceWidths[i] = pieceWidth; totalPieceWidth += pieceWidth; } float boxHeight = PT_FONT.getCapHeight() + PT_FONT.getAscent() + 3 * padding; @@ -324,7 +324,7 @@ public class CardImageRenderer { x += (boxWidth - totalPieceWidth) / 2; for (int i = 0; i < pieces.size(); i++) { g.drawText(pieces.get(i), PT_FONT, Color.BLACK, x, y, w, h, false, HAlignment.LEFT, true); - x += pieceWidths.get(i); + x += pieceWidths[i]; } }