From a5f11a5f9eb0af70e580d15ed87c01530b13d98d Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 13 Mar 2024 14:39:43 -0400 Subject: util.join() is unnecessary: luau provides table.concat(). --- indra/newview/scripts/lua/util.lua | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/indra/newview/scripts/lua/util.lua b/indra/newview/scripts/lua/util.lua index 898ddc58e3..e3af633ea7 100644 --- a/indra/newview/scripts/lua/util.lua +++ b/indra/newview/scripts/lua/util.lua @@ -36,34 +36,4 @@ function util.equal(t1, t2) return util.empty(temp) end --- Concatentate the strings in the passed list, return the composite string. --- For iterative string building, the theory is that building a list with --- table.insert() and then using join() to allocate the full-size result --- string once should be more efficient than reallocating an intermediate --- string for every partial concatenation. -function util.join(list, sep) - -- This succinct implementation assumes that string.format() precomputes - -- the required size of its output buffer before populating it. We don't - -- know that. Moreover, this implementation predates our sep argument. --- return string.format(string.rep('%s', #list), table.unpack(list)) - - -- this implementation makes it explicit - local sep = sep or '' - local size = if util.empty(list) then 0 else -#sep - for _, s in pairs(list) do - size += #sep + #s - end - local result = buffer.create(size) - size = 0 - for i, s in pairs(list) do - if i > 1 then - buffer.writestring(result, size, sep) - size += #sep - end - buffer.writestring(result, size, s) - size += #s - end - return buffer.tostring(result) -end - return util -- cgit v1.2.3