summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-03-25 17:35:28 -0400
committerNat Goodspeed <nat@lindenlab.com>2024-03-25 17:35:28 -0400
commit5b04ae7812e6cb0d0c9895aec6db6a206d4e09e8 (patch)
tree5ad2b88bc4376cf9f984c7d084ee249ecc9456ca
parent98e6356aed0c757f16267cc2ae921f9c90a249fe (diff)
util.lua claims functions are in alpha order - make it so.
Also streamline util.contains(), given table.find().
-rw-r--r--indra/newview/scripts/lua/util.lua21
1 files changed, 8 insertions, 13 deletions
diff --git a/indra/newview/scripts/lua/util.lua b/indra/newview/scripts/lua/util.lua
index 5d6042dfe5..a2191288f6 100644
--- a/indra/newview/scripts/lua/util.lua
+++ b/indra/newview/scripts/lua/util.lua
@@ -2,9 +2,9 @@
local util = {}
--- cheap test whether table t is empty
-function util.empty(t)
- return not next(t)
+-- check if array-like table contains certain value
+function util.contains(t, v)
+ return table.find(t, v) ~= nil
end
-- reliable count of the number of entries in table t
@@ -17,6 +17,11 @@ function util.count(t)
return count
end
+-- cheap test whether table t is empty
+function util.empty(t)
+ return not next(t)
+end
+
-- recursive table equality
function util.equal(t1, t2)
if not (type(t1) == 'table' and type(t2) == 'table') then
@@ -36,14 +41,4 @@ function util.equal(t1, t2)
return util.empty(temp)
end
--- check if array-like table contains certain value
-function util.contains(t, v)
- for _, value in ipairs(t) do
- if value == v then
- return true
- end
- end
- return false
-end
-
return util