From f919349173d8dae2d895b3419057ea453663be5c Mon Sep 17 00:00:00 2001 From: Maxim Ignatenko Date: Tue, 20 Sep 2011 20:27:08 +0300 Subject: [PATCH] Use more pattern-matching --- src/mod_muc/mod_muc_room.erl | 38 ++++++++++++------------------------ 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/src/mod_muc/mod_muc_room.erl b/src/mod_muc/mod_muc_room.erl index bd26b74d0..c191c4122 100644 --- a/src/mod_muc/mod_muc_room.erl +++ b/src/mod_muc/mod_muc_room.erl @@ -3735,18 +3735,12 @@ is_voice_request({xmlelement, "x", _, _} = Elem) -> end; is_voice_request(Els) -> lists:foldl( - fun(X, Acc) -> - case Acc of - false -> - case X of - {xmlelement, "x", _, _} -> - is_voice_request(X); - _ -> - false - end; - true -> - true - end + fun(_, true) -> + true; + ({xmlelement, "x", _, _} = X, false) -> + is_voice_request(X); + (_, _) -> + false end, false, Els). check_voice_request_fields(_, false) -> @@ -3805,18 +3799,12 @@ is_voice_approvement({xmlelement, "x", _, _} = Elem) -> end; is_voice_approvement(Els) -> lists:foldl( - fun(X, Acc) -> - case Acc of - false -> - case X of - {xmlelement, "x", _, _} -> - is_voice_approvement(X); - _ -> - false - end; - true -> - true - end + fun(_, true) -> + true; + ({xmlelement, "x", _, _} = X, false) -> + is_voice_approvement(X); + (_, _) -> + false end, false, Els). check_voice_approvement_fields(_, false) -> @@ -3836,7 +3824,7 @@ check_voice_approvement_fields({"muc#request_allow", "1"}, true) -> check_voice_approvement_fields({"muc#request_allow", _}, _) -> false; check_voice_approvement_fields(_, true) -> - true; % do not check any other fields + true. % do not check any other fields extract_jid_from_voice_approvement(Els) -> lists:foldl(