From f5262fad08054a8ff897610bb6090bc449aa635e Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Wed, 4 Mar 2020 15:34:27 +1100 Subject: [PATCH] replaced toint with a shorter version --- lz16/liblz16.lua | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lz16/liblz16.lua b/lz16/liblz16.lua index 140c4c1..e4ef668 100644 --- a/lz16/liblz16.lua +++ b/lz16/liblz16.lua @@ -11,15 +11,11 @@ local function cint(n,l) return string.reverse(string.char(table.unpack(t)):sub(1,l)) end local function toint(s) - s=s or "" local n = 0 local i = 1 - while true do - local p = s:sub(i,i) - if p == "" then break end - local b = string.byte(p) + for p in s:gmatch(".") do n = n << 8 - n = n | b + n = n | string.byte(p) i=i+1 end return n