diff options
author | Anders Svensson <[email protected]> | 2017-04-21 15:41:00 +0200 |
---|---|---|
committer | Anders Svensson <[email protected]> | 2017-06-12 16:13:52 +0200 |
commit | d6b15a127ec9263bd9ec8571ec577f4e7e304182 (patch) | |
tree | dd213eacd2eb16685ef39ee972093825ee210335 /lib | |
parent | fb75d1cf29ba5f63de021f3cb4e7165ed265be3c (diff) | |
download | otp-d6b15a127ec9263bd9ec8571ec577f4e7e304182.tar.gz otp-d6b15a127ec9263bd9ec8571ec577f4e7e304182.tar.bz2 otp-d6b15a127ec9263bd9ec8571ec577f4e7e304182.zip |
Simplify value setting at decode
Diffstat (limited to 'lib')
-rw-r--r-- | lib/diameter/include/diameter_gen.hrl | 25 |
1 files changed, 10 insertions, 15 deletions
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 %% --------------------------------------------------------------------------- |