From 34783cfe946ccff5378dc8aeb58df5d51af2eb89 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 25 Aug 2025 03:21:48 +0200 Subject: [PATCH] dont evaluate strtol multiple times --- src/blua/luaconf.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/blua/luaconf.h b/src/blua/luaconf.h index 9766959c9..1fa50023f 100644 --- a/src/blua/luaconf.h +++ b/src/blua/luaconf.h @@ -535,8 +535,11 @@ #endif #define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) #define LUAI_MAXNUMBER2STR 12 /* 10 digits, sign, and \0 */ -#define lua_str2number(s,p) max(INT32_MIN, min((strtol((s), (p), 10)), INT32_MAX)); - +#define lua_str2number(s,p) ({ \ + long nmr = strtol((s), (p), 10); \ + nmr = max(INT32_MIN, min((nmr), INT32_MAX)); \ + nmr; \ + }) /* @@ The luai_num* macros define the primitive operations over numbers.