Skip to content

Commit

Permalink
enhancement(table.basically_the_same): Check object equality
Browse files Browse the repository at this point in the history
  • Loading branch information
dabrady committed Sep 22, 2020
1 parent 488a423 commit 54ca448
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions table.lua
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,11 @@ end
function module.basically_the_same(t1, t2)
assert(type(t1) == "table" and type(t2) == "table")

if t1 == t2 then
-- They're actually the same.
return true
end

-- NOTE(dabrady) If the two tables are lists and have the same length,
-- we could short-circuit one of these loops. But determining whether
-- they are lists is more expensive than just doing the two loops here.
Expand Down

0 comments on commit 54ca448

Please sign in to comment.