diff options
author | Steven Barth <steven@midlink.org> | 2008-09-09 12:44:41 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-09-09 12:44:41 +0000 |
commit | 8dbf29e86e984e9de87ad0724a99cab89f2d8ea6 (patch) | |
tree | 158b52a64bd1ac91e5dff563f939b18b5084af84 /libs/core/luasrc | |
parent | 023b4ddf646438cfb0a468fdcb3a32945b239e20 (diff) |
Performance optimisations:
In-line expressions are faster than function calls
Diffstat (limited to 'libs/core/luasrc')
-rw-r--r-- | libs/core/luasrc/ltn12.lua | 4 | ||||
-rw-r--r-- | libs/core/luasrc/util.lua | 12 |
2 files changed, 8 insertions, 8 deletions
diff --git a/libs/core/luasrc/ltn12.lua b/libs/core/luasrc/ltn12.lua index c9b663463f..9371290c61 100644 --- a/libs/core/luasrc/ltn12.lua +++ b/libs/core/luasrc/ltn12.lua @@ -190,7 +190,7 @@ function source.rewind(src) if not chunk then return src() else return chunk end else - table.insert(t, chunk) + t[#t+1] = chunk end end end @@ -277,7 +277,7 @@ end function sink.table(t) t = t or {} local f = function(chunk, err) - if chunk then table.insert(t, chunk) end + if chunk then t[#t+1] = chunk end return 1 end return f, t diff --git a/libs/core/luasrc/util.lua b/libs/core/luasrc/util.lua index 235b0c22c2..5f9c609f65 100644 --- a/libs/core/luasrc/util.lua +++ b/libs/core/luasrc/util.lua @@ -249,9 +249,9 @@ function split(str, pat, max, regex) local s, e = str:find(pat, c, not regex) max = max - 1 if s and max < 0 then - table.insert(t, str:sub(c)) + t[#t+1] = str:sub(c) else - table.insert(t, str:sub(c, s and s - 1)) + t[#t+1] = str:sub(c, s and s - 1) end c = e and e + 1 or #str + 1 until not s or max < 0 @@ -334,7 +334,7 @@ function combine(...) local result = {} for i, a in ipairs(arg) do for j, v in ipairs(a) do - table.insert(result, v) + result[#result+1] = v end end return result @@ -371,7 +371,7 @@ function keys(t) local keys = { } if t then for k, _ in kspairs(t) do - table.insert( keys, k ) + keys[#keys+1] = k end end return keys @@ -568,7 +568,7 @@ function _sortiter( t, f ) local keys = { } for k, v in pairs(t) do - table.insert( keys, k ) + keys[#keys+1] = k end local _pos = 0 @@ -657,7 +657,7 @@ function execl(command) while true do line = pp:read() if (line == nil) then break end - table.insert(data, line) + data[#data+1] = line end pp:close() |