Software /
code /
prosody
Comparison
util/set.lua @ 11120:b2331f3dfeea
Merge 0.11->trunk
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 30 Sep 2020 09:50:33 +0100 |
parent | 10594:13d5fb74648f |
child | 11560:3bbb1af92514 |
comparison
equal
deleted
inserted
replaced
11119:68df52bf08d5 | 11120:b2331f3dfeea |
---|---|
6 -- COPYING file in the source package for more information. | 6 -- COPYING file in the source package for more information. |
7 -- | 7 -- |
8 | 8 |
9 local ipairs, pairs, setmetatable, next, tostring = | 9 local ipairs, pairs, setmetatable, next, tostring = |
10 ipairs, pairs, setmetatable, next, tostring; | 10 ipairs, pairs, setmetatable, next, tostring; |
11 local getmetatable = getmetatable; | |
11 local t_concat = table.concat; | 12 local t_concat = table.concat; |
12 | 13 |
13 local _ENV = nil; | 14 local _ENV = nil; |
14 -- luacheck: std none | 15 -- luacheck: std none |
15 | 16 |
144 end | 145 end |
145 end | 146 end |
146 return new_set; | 147 return new_set; |
147 end | 148 end |
148 function set_mt.__eq(set1, set2) | 149 function set_mt.__eq(set1, set2) |
150 if getmetatable(set1) ~= set_mt or getmetatable(set2) ~= set_mt then | |
151 -- Lua 5.3+ calls this if both operands are tables, even if metatables differ | |
152 return false; | |
153 end | |
154 | |
149 set1, set2 = set1._items, set2._items; | 155 set1, set2 = set1._items, set2._items; |
150 for item in pairs(set1) do | 156 for item in pairs(set1) do |
151 if not set2[item] then | 157 if not set2[item] then |
152 return false; | 158 return false; |
153 end | 159 end |