From 2253fcc955070ed3a080d1e01c95d99c47d236df Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 6 Apr 2026 09:05:47 +0500 Subject: [PATCH] ref: gl: skip redundant positions in LM_AllocBlock --- ref/gl/gl_rsurf.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ref/gl/gl_rsurf.c b/ref/gl/gl_rsurf.c index bd6e4e8c..c7113a84 100644 --- a/ref/gl/gl_rsurf.c +++ b/ref/gl/gl_rsurf.c @@ -662,7 +662,7 @@ static int LM_AllocBlock( int w, int h, int *x, int *y ) best = BLOCK_SIZE; - for( i = 0; i < BLOCK_SIZE - w; i++ ) + for( i = 0; i < BLOCK_SIZE - w; ) { best2 = 0; @@ -679,6 +679,12 @@ static int LM_AllocBlock( int w, int h, int *x, int *y ) // this is a valid spot *x = i; *y = best = best2; + i++; + } + else + { + // allocated[i+j] was too tall — no position in [i, i+j] can work + i += j + 1; } }