diff options
author | Matthias Radestock <matthias@rabbitmq.com> | 2012-11-21 15:19:00 +0000 |
---|---|---|
committer | Matthias Radestock <matthias@rabbitmq.com> | 2012-11-21 15:19:00 +0000 |
commit | 5d308a066213334a009ae2edbb980e974279c9bd (patch) | |
tree | bd9dafdd3540b4fe20c8d88e0941c95181481bbb | |
parent | 15edd1b2359b9530fe18214710e026dba2b2d6e2 (diff) | |
download | rabbitmq-server-5d308a066213334a009ae2edbb980e974279c9bd.tar.gz |
simplify & optimise rabbit_exchange:callback/4
-rw-r--r-- | src/rabbit_exchange.erl | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/rabbit_exchange.erl b/src/rabbit_exchange.erl index a205b23d..f209b3ca 100644 --- a/src/rabbit_exchange.erl +++ b/src/rabbit_exchange.erl @@ -39,8 +39,7 @@ -spec(recover/0 :: () -> [name()]). -spec(callback/4:: (rabbit_types:exchange(), fun_name(), - fun((boolean()) -> non_neg_integer()) | atom(), - [any()]) -> 'ok'). + fun((boolean()) -> non_neg_integer()) | atom(), [any()]) -> 'ok'). -spec(policy_changed/2 :: (rabbit_types:exchange(), rabbit_types:exchange()) -> 'ok'). -spec(declare/6 :: @@ -114,14 +113,11 @@ recover() -> [XName || #exchange{name = XName} <- Xs]. callback(X = #exchange{type = XType}, Fun, Serial0, Args) -> - Serial = fun (Bool) -> - case Serial0 of - _ when is_atom(Serial0) -> Serial0; - _ -> Serial0(Bool) - end + Serial = if is_function(Serial0) -> Serial0; + is_atom(Serial0) -> fun (_Bool) -> Serial0 end end, - [ok = apply(M, Fun, [Serial(M:serialise_events(X)) | Args]) - || M <- decorators()], + [ok = apply(M, Fun, [Serial(M:serialise_events(X)) | Args]) || + M <- decorators()], Module = type_to_module(XType), apply(Module, Fun, [Serial(Module:serialise_events()) | Args]). |