Skip to content

Commit e58525e

Browse files
author
Simon MacMullen
committed
Slight simplification that these vars are declared once and failure is a thunk.
1 parent 04bfde7 commit e58525e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/rabbit_misc.erl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,21 +250,23 @@ assert_args_equivalence(Orig, New, Name, Keys) ->
250250
ok.
251251

252252
assert_args_equivalence1(Orig, New, Name, Key) ->
253-
FailureFun = fun (Orig1, New1) ->
253+
{Orig1, New1} = {table_lookup(Orig, Key), table_lookup(New, Key)},
254+
FailureFun = fun () ->
254255
protocol_error(precondition_failed, "inequivalent arg '~s'"
255256
"for ~s: received ~s but current is ~s",
256257
[Key, rs(Name), val(New1), val(Orig1)])
257258
end,
258-
case {table_lookup(Orig, Key), table_lookup(New, Key)} of
259+
case {Orig1, New1} of
259260
{Same, Same} ->
260261
ok;
261-
{{OrigType, OrigVal} = Orig1, {NewType, NewVal} = New1} ->
262+
{{OrigType, OrigVal}, {NewType, NewVal}} ->
262263
case type_class(OrigType) == type_class(NewType) andalso
263264
OrigVal == NewVal of
264265
true -> ok;
265-
false -> FailureFun(Orig1, New1)
266+
false -> FailureFun()
266267
end;
267-
{Orig1, New1} -> FailureFun(Orig1, New1)
268+
{_, _} ->
269+
FailureFun()
268270
end.
269271

270272
val(undefined) ->

0 commit comments

Comments
 (0)