22
33---- ----------------------------------------------------------------------------
44-- Localize functions to avoid table lookups (better performance).
5- local table_insert = table.insert
65local string_sub , string_find = string.sub , string.find
76
87---- ----------------------------------------------------------------------------
@@ -94,13 +93,13 @@ function dump2(o, name, dumped)
9493 -- the form _G["table: 0xFFFFFFF"]
9594 keyStr = string.format (" _G[%q]" , tostring (k ))
9695 -- Dump key table
97- table_insert ( t , dump2 (k , keyStr , dumped ) )
96+ t [ # t + 1 ] = dump2 (k , keyStr , dumped )
9897 end
9998 else
10099 keyStr = basic_dump (k )
101100 end
102101 local vname = string.format (" %s[%s]" , name , keyStr )
103- table_insert ( t , dump2 (v , vname , dumped ) )
102+ t [ # t + 1 ] = dump2 (v , vname , dumped )
104103 end
105104 return string.format (" %s = {}\n %s" , name , table.concat (t ))
106105end
@@ -135,7 +134,7 @@ function dump(o, indent, nested, level)
135134 local t = {}
136135 local dumped_indexes = {}
137136 for i , v in ipairs (o ) do
138- table_insert ( t , dump (v , indent , nested , level + 1 ) )
137+ t [ # t + 1 ] = dump (v , indent , nested , level + 1 )
139138 dumped_indexes [i ] = true
140139 end
141140 for k , v in pairs (o ) do
@@ -144,7 +143,7 @@ function dump(o, indent, nested, level)
144143 k = " [" .. dump (k , indent , nested , level + 1 ).. " ]"
145144 end
146145 v = dump (v , indent , nested , level + 1 )
147- table_insert ( t , k .. " = " .. v )
146+ t [ # t + 1 ] = k .. " = " .. v
148147 end
149148 end
150149 nested [o ] = nil
@@ -177,7 +176,7 @@ function string.split(str, delim, include_empty, max_splits, sep_is_pattern)
177176 local s = string_sub (str , pos , np - 1 )
178177 if include_empty or (s ~= " " ) then
179178 max_splits = max_splits - 1
180- table_insert ( items , s )
179+ items [ # items + 1 ] = s
181180 end
182181 pos = npe + 1
183182 until (max_splits == 0 ) or (pos > (len + 1 ))
186185
187186---- ----------------------------------------------------------------------------
188187function table .indexof (list , val )
189- for i = 1 , # list do
190- if list [ i ] == val then
188+ for i , v in ipairs ( list ) do
189+ if v == val then
191190 return i
192191 end
193192 end
@@ -324,7 +323,7 @@ function core.splittext(text,charlimit)
324323 local last_line = " "
325324 while start ~= nil do
326325 if string.len (last_line ) + (stop - start ) > charlimit then
327- table_insert ( retval , last_line )
326+ retval [ # retval + 1 ] = last_line
328327 last_line = " "
329328 end
330329
@@ -335,7 +334,7 @@ function core.splittext(text,charlimit)
335334 last_line = last_line .. string_sub (text , current_idx , stop - 1 )
336335
337336 if gotnewline then
338- table_insert ( retval , last_line )
337+ retval [ # retval + 1 ] = last_line
339338 last_line = " "
340339 gotnewline = false
341340 end
@@ -353,11 +352,11 @@ function core.splittext(text,charlimit)
353352
354353 -- add last part of text
355354 if string.len (last_line ) + (string.len (text ) - current_idx ) > charlimit then
356- table_insert ( retval , last_line )
357- table_insert ( retval , string_sub (text , current_idx ) )
355+ retval [ # retval + 1 ] = last_line
356+ retval [ # retval + 1 ] = string_sub (text , current_idx )
358357 else
359358 last_line = last_line .. " " .. string_sub (text , current_idx )
360- table_insert ( retval , last_line )
359+ retval [ # retval + 1 ] = last_line
361360 end
362361
363362 return retval
@@ -430,14 +429,14 @@ if INIT == "game" then
430429
431430 if iswall then
432431 core .set_node (pos , {name = wield_name ,
433- param2 = dirs1 [fdir + 1 ]})
432+ param2 = dirs1 [fdir + 1 ]})
434433 elseif isceiling then
435434 if orient_flags .force_facedir then
436435 core .set_node (pos , {name = wield_name ,
437436 param2 = 20 })
438437 else
439438 core .set_node (pos , {name = wield_name ,
440- param2 = dirs2 [fdir + 1 ]})
439+ param2 = dirs2 [fdir + 1 ]})
441440 end
442441 else -- place right side up
443442 if orient_flags .force_facedir then
0 commit comments