Skip to content

Commit

Permalink
improve to_array
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Oct 6, 2024
1 parent 0ee97cd commit 44f05cd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions tests/modules/hashset/test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ function test_hashset(t)
t:require(h == h2)
h2:clear()
t:require(h2:empty())
t:require(h == hashset.from(h:to_array()))
end

6 changes: 3 additions & 3 deletions xmake/core/base/hashset.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ end
-- convert hashset to an array, nil in the set will be ignored
function hashset:to_array()
local result = {}
for k, _ in pairs(self._DATA) do
if k ~= hashset._NIL then
table.insert(result, k)
for item in self:items() do
if item ~= nil then
table.insert(result, item)
end
end
return result
Expand Down

0 comments on commit 44f05cd

Please sign in to comment.