File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 66local logger = require (" logger" );
77local bit32 = require (" prometheus.bit" ).bit32 ;
88
9+ local MAX_UNPACK_COUNT = 195 ;
10+
911local function lookupify (tb )
1012 local tb2 = {};
1113 for _ , v in ipairs (tb ) do
@@ -222,11 +224,20 @@ local function readU32(arr)
222224end
223225
224226local function bytesToString (arr )
227+ local lenght = arr .n or # arr ;
228+
229+ if lenght < MAX_UNPACK_COUNT then
230+ return string.char (table.unpack (arr ))
231+ end
232+
225233 local str = " " ;
226- for i = 1 , # arr do
227- str = str .. string.char (arr [i ]);
234+ local overflow = lenght % MAX_UNPACK_COUNT ;
235+
236+ for i = 1 , (# arr - overflow ) / MAX_UNPACK_COUNT do
237+ str = str .. string.char (table.unpack (arr , (i - 1 ) * MAX_UNPACK_COUNT + 1 , i * MAX_UNPACK_COUNT ));
228238 end
229- return str ;
239+
240+ return str .. string.char (table.unpack (arr , lenght - overflow + 1 , lenght ));
230241end
231242
232243local function isNaN (n )
You can’t perform that action at this time.
0 commit comments