mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
ArrayList of Floats -> float[] to avoid a bunch of temp allocations in frequently called code.
This commit is contained in:
@@ -299,10 +299,10 @@ public class CardImageRenderer {
|
|||||||
|
|
||||||
float padding = Math.round(PT_FONT.getCapHeight() / 4);
|
float padding = Math.round(PT_FONT.getCapHeight() / 4);
|
||||||
float totalPieceWidth = -padding;
|
float totalPieceWidth = -padding;
|
||||||
List<Float> pieceWidths = new ArrayList<Float>();
|
float[] pieceWidths = new float[pieces.size()];
|
||||||
for (String piece : pieces) {
|
for (int i = 0; i < pieces.size(); i++) {
|
||||||
float pieceWidth = PT_FONT.getBounds(piece).width + padding;
|
float pieceWidth = PT_FONT.getBounds(pieces.get(i)).width + padding;
|
||||||
pieceWidths.add(pieceWidth);
|
pieceWidths[i] = pieceWidth;
|
||||||
totalPieceWidth += pieceWidth;
|
totalPieceWidth += pieceWidth;
|
||||||
}
|
}
|
||||||
float boxHeight = PT_FONT.getCapHeight() + PT_FONT.getAscent() + 3 * padding;
|
float boxHeight = PT_FONT.getCapHeight() + PT_FONT.getAscent() + 3 * padding;
|
||||||
@@ -324,7 +324,7 @@ public class CardImageRenderer {
|
|||||||
x += (boxWidth - totalPieceWidth) / 2;
|
x += (boxWidth - totalPieceWidth) / 2;
|
||||||
for (int i = 0; i < pieces.size(); i++) {
|
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);
|
g.drawText(pieces.get(i), PT_FONT, Color.BLACK, x, y, w, h, false, HAlignment.LEFT, true);
|
||||||
x += pieceWidths.get(i);
|
x += pieceWidths[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user