From f6b7669798da7d969c5246f569dd0cde2ba2ae8a Mon Sep 17 00:00:00 2001 From: Gregor Lohaus Date: Tue, 2 Jun 2026 11:11:33 +0200 Subject: [PATCH] memory savings --- .../com/gregor/jprototerm/GhosttyTerminalRenderer.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gregor/jprototerm/GhosttyTerminalRenderer.java b/src/main/java/com/gregor/jprototerm/GhosttyTerminalRenderer.java index 76a92eb..940d42c 100644 --- a/src/main/java/com/gregor/jprototerm/GhosttyTerminalRenderer.java +++ b/src/main/java/com/gregor/jprototerm/GhosttyTerminalRenderer.java @@ -817,18 +817,20 @@ final class GhosttyTerminalRenderer extends TerminalRenderer { int blue = rgb & 0xff; // Clamp the glyph rectangle to the buffer once, so the inner loops carry no // per-pixel bounds check (this is the hottest pixel loop on a text repaint). + int glyphWidth = glyph.width(); + byte[] glyphAlpha = glyph.alpha(); int gyStart = Math.max(0, -y); - int gyEnd = Math.min(glyph.height, height - y); + int gyEnd = Math.min(glyph.height(), height - y); int gxStart = Math.max(0, -x); - int gxEnd = Math.min(glyph.width, width - x); + int gxEnd = Math.min(glyphWidth, width - x); if (gyStart >= gyEnd || gxStart >= gxEnd) { return; } for (int gy = gyStart; gy < gyEnd; gy++) { int rowOffset = (y + gy) * width; - int glyphOffset = gy * glyph.width; + int glyphOffset = gy * glyphWidth; for (int gx = gxStart; gx < gxEnd; gx++) { - int alpha = glyph.alpha[glyphOffset + gx] & 0xff; + int alpha = glyphAlpha[glyphOffset + gx] & 0xff; if (alpha == 0) { continue; }