Skip to content

Commit 77bde77

Browse files
author
José Valim
committed
Calculate target just once
1 parent 2e96d1d commit 77bde77

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/elixir/lib/dict.ex

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,12 +335,15 @@ defmodule Dict do
335335
"""
336336
@spec equal?(t, t) :: boolean
337337
def equal?(a, b) do
338+
a_target = target(a)
339+
b_target = target(b)
340+
338341
cond do
339-
target(a) == target(b) ->
340-
target(a).equal?(a, b)
342+
a_target == b_target ->
343+
a_target.equal?(a, b)
341344

342-
target(a).size(a) == target(b).size(b) ->
343-
List.Dict.equal?(target(a).to_list(a), target(b).to_list(b))
345+
a_target.size(a) == b_target.size(b) ->
346+
List.Dict.equal?(a_target.to_list(a), b_target.to_list(b))
344347

345348
true ->
346349
false

0 commit comments

Comments
 (0)