mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-26 09:13:53 +01:00
Fix bluon:len
This commit is contained in:
parent
e28ee76d7d
commit
f6a3f31c13
12
bluon.lua
12
bluon.lua
@ -95,9 +95,14 @@ local function is_map_key(key, list_len)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function len(self, object)
|
function len(self, object)
|
||||||
|
if object == nil then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
if constants[object] then
|
if constants[object] then
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
local object_ids = {}
|
||||||
|
local current_id = 0
|
||||||
local _type = type(object)
|
local _type = type(object)
|
||||||
if _type == "number" then
|
if _type == "number" then
|
||||||
if object ~= object then
|
if object ~= object then
|
||||||
@ -126,7 +131,6 @@ function len(self, object)
|
|||||||
if _type == "table" then
|
if _type == "table" then
|
||||||
if next(object) == nil then
|
if next(object) == nil then
|
||||||
-- empty {} table
|
-- empty {} table
|
||||||
byte(type_ranges.string + 1)
|
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
local list_len = #object
|
local list_len = #object
|
||||||
@ -138,14 +142,14 @@ function len(self, object)
|
|||||||
end
|
end
|
||||||
local table_len = 1 + uint_len(list_len) + uint_len(kv_len)
|
local table_len = 1 + uint_len(list_len) + uint_len(kv_len)
|
||||||
for index = 1, list_len do
|
for index = 1, list_len do
|
||||||
table_len = table_len + len(self, object[index])
|
table_len = table_len + self:len(object[index])
|
||||||
end
|
end
|
||||||
for key, value in pairs(object) do
|
for key, value in pairs(object) do
|
||||||
if is_map_key(key, list_len) then
|
if is_map_key(key, list_len) then
|
||||||
table_len = table_len + len(self, key) + len(self, value)
|
table_len = table_len + self:len(key) + self:len(value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return len
|
return kv_len + table_len
|
||||||
end
|
end
|
||||||
return self.aux_len(object)
|
return self.aux_len(object)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user