From d6b15a127ec9263bd9ec8571ec577f4e7e304182 Mon Sep 17 00:00:00 2001 From: Anders Svensson Date: Fri, 21 Apr 2017 15:41:00 +0200 Subject: Simplify value setting at decode --- lib/diameter/include/diameter_gen.hrl | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'lib/diameter') diff --git a/lib/diameter/include/diameter_gen.hrl b/lib/diameter/include/diameter_gen.hrl index 1b79aa6d32..4624d42c6f 100644 --- a/lib/diameter/include/diameter_gen.hrl +++ b/lib/diameter/include/diameter_gen.hrl @@ -635,8 +635,11 @@ pack(Arity, FieldName, Avp, {Rec, _} = Acc) -> %% pack/5 -pack(undefined, 1, FieldName, Avp, Acc) -> - p(FieldName, fun(V) -> V end, Avp, Acc); +pack(undefined, 1, 'AVP' = F, Avp, {Rec, Failed}) -> %% unlikely + {'#set-'({F, Avp}, Rec), Failed}; + +pack(undefined, 1, F, #diameter_avp{value = V}, {Rec, Failed}) -> + {'#set-'({F, V}, Rec), Failed}; %% 3588: %% @@ -649,25 +652,17 @@ pack(undefined, 1, FieldName, Avp, Acc) -> pack(_, 1, _, Avp, {Rec, Failed}) -> {Rec, [{5009, Avp} | Failed]}; -pack(L, {_, Max}, FieldName, Avp, Acc) -> + +pack(L, {_, Max}, F, Avp, {Rec, Failed}) -> case '*' /= Max andalso has_prefix(Max, L) of true -> - {Rec, Failed} = Acc, {Rec, [{5009, Avp} | Failed]}; + false when F == 'AVP' -> + {'#set-'({F, [Avp | L]}, Rec), Failed}; false -> - p(FieldName, fun(V) -> [V|L] end, Avp, Acc) + {'#set-'({F, [Avp#diameter_avp.value | L]}, Rec), Failed} end. -%% p/4 - -p(F, Fun, Avp, {Rec, Failed}) -> - {'#set-'({F, Fun(value(F, Avp))}, Rec), Failed}. - -value('AVP', Avp) -> - Avp; -value(_, Avp) -> - Avp#diameter_avp.value. - %% --------------------------------------------------------------------------- %% # grouped_avp/3 %% --------------------------------------------------------------------------- -- cgit v1.2.3