From c3a8d94a83f21495e62b392cb6391ece9cd3c898 Mon Sep 17 00:00:00 2001 From: Xurkon Date: Mon, 16 Mar 2026 19:35:24 -0500 Subject: [PATCH] fix: replace table.getn with # operator in XXH_Lua_Lib (string not table) --- Libs/XXH_Lua_Lib/XXH_Lua_Lib.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Libs/XXH_Lua_Lib/XXH_Lua_Lib.lua b/Libs/XXH_Lua_Lib/XXH_Lua_Lib.lua index 533e6ec..37bc7d7 100644 --- a/Libs/XXH_Lua_Lib/XXH_Lua_Lib.lua +++ b/Libs/XXH_Lua_Lib/XXH_Lua_Lib.lua @@ -96,7 +96,7 @@ end -- ========================================================================= local function XXH32(str, seed) - local len = table.getn(str) + local len = #str seed = band(seed or 0, U32_MASK) local h32 @@ -283,7 +283,7 @@ end local function XXH64_small(str, seed) -- Specialized fast path for len <= 16 (avoids extra branching/loops) - local len = table.getn(str) + local len = #str local h_hi, h_lo = 0, band(seed or 0, U32_MASK) -- h = seed + P5 h_hi, h_lo = add64(h_hi, h_lo, P64_5_H, P64_5_L) @@ -343,7 +343,7 @@ local function XXH64_small(str, seed) end local function XXH64(str, seed) - local len = table.getn(str) + local len = #str if len <= 16 then return XXH64_small(str, seed) end @@ -436,7 +436,7 @@ local function XXH64(str, seed) end -- 4-byte tail: h ^= (read32 * P1); h = rotl(h, 23) * P2 + P3 - if index <= table.getn(str) - 3 then + if index <= #str - 3 then local v32 = read_u32_le(str, index) local m_h, m_l = mul_u32_const64(v32, P64_1_H, P64_1_L) h_hi = bxor(h_hi, m_h); h_lo = bxor(h_lo, m_l) @@ -447,7 +447,7 @@ local function XXH64(str, seed) end -- 1-byte tails: for each b, h ^= (b * P5); h = rotl(h, 11) * P1 - while index <= table.getn(str) do + while index <= #str do local b = sbyte(str, index) local m_h, m_l = mul_u32_const64(b, P64_5_H, P64_5_L) h_hi = bxor(h_hi, m_h); h_lo = bxor(h_lo, m_l) @@ -477,8 +477,8 @@ end local function to_hex_bytes(str) local t = {} - for i = 1, table.getn(str) do - t[table.getn(t) + 1] = string.format("%02X", sbyte(str, i)) + for i = 1, #str do + t[#t + 1] = string.format("%02X", sbyte(str, i)) end return table.concat(t, " ") end @@ -486,7 +486,7 @@ end local function parse_hex_bytes(hex) local out = {} for byte in string.gmatch(hex, "%x%x") do - out[table.getn(out) + 1] = string.char(tonumber(byte, 16)) + out[#out + 1] = string.char(tonumber(byte, 16)) end return table.concat(out) end