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