diff options
author | Anders Svensson <[email protected]> | 2017-04-16 01:14:14 +0200 |
---|---|---|
committer | Anders Svensson <[email protected]> | 2017-06-12 16:13:52 +0200 |
commit | 501cd3fae71dcbcf56da55748abd82b512127220 (patch) | |
tree | 7dbde5a449fb6aed2fc088748aa9e89e17a8ba35 /lib/diameter/include/diameter_gen.hrl | |
parent | 836b02d325082063fc5887091bfc04db6afab181 (diff) | |
download | otp-501cd3fae71dcbcf56da55748abd82b512127220.tar.gz otp-501cd3fae71dcbcf56da55748abd82b512127220.tar.bz2 otp-501cd3fae71dcbcf56da55748abd82b512127220.zip |
Simplify missing AVP detection
By using the existing '#get-'/1 in generated dictionary modules to
retrieve fields and values at the same time.
Before:
{[{{diameter_gen_base_rfc6733,missing,3}, 1000, 211.722, 8.741},
{{diameter_gen_base_rfc6733,'-missing/3-lc$^0/1-0-',4},12000, 0.000, 95.764}],
{ {diameter_gen_base_rfc6733,'-missing/3-lc$^0/1-0-',4},13000, 211.722, 104.505}, %
[{{diameter_gen_base_rfc6733,'#get-',2}, 12000, 49.917, 28.221},
{{diameter_gen_base_rfc6733,has_arity,2}, 12000, 31.811, 23.442},
{{diameter_gen_base_rfc6733,avp_arity,2}, 12000, 21.076, 20.975},
{garbage_collect, 457, 3.918, 3.918},
{suspend, 31, 0.495, 0.000},
{{diameter_gen_base_rfc6733,'-missing/3-lc$^0/1-0-',4},12000, 0.000, 95.764}]}.
After:
{[{{diameter_gen_base_rfc6733,missing,3}, 1000, 134.098, 2.402},
{{diameter_gen_base_rfc6733,'-missing/3-lc$^0/1-0-',3},13000, 0.000, 77.327}],
{ {diameter_gen_base_rfc6733,'-missing/3-lc$^0/1-0-',3},14000, 134.098, 79.729}, %
[{{diameter_gen_base_rfc6733,has_arity,2}, 12000, 31.084, 22.913},
{{diameter_gen_base_rfc6733,avp_arity,2}, 12000, 20.526, 20.440},
{garbage_collect, 253, 2.504, 2.504},
{suspend, 17, 0.255, 0.000},
{{diameter_gen_base_rfc6733,'-missing/3-lc$^0/1-0-',3},13000, 0.000, 77.327}]}.
Diffstat (limited to 'lib/diameter/include/diameter_gen.hrl')
-rw-r--r-- | lib/diameter/include/diameter_gen.hrl | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/diameter/include/diameter_gen.hrl b/lib/diameter/include/diameter_gen.hrl index f7d432912d..09af829259 100644 --- a/lib/diameter/include/diameter_gen.hrl +++ b/lib/diameter/include/diameter_gen.hrl @@ -213,11 +213,10 @@ missing(Rec, Name, Failed) -> end, maps:new(), Failed), - [{5005, A} || F <- '#info-'(element(1, Rec), fields), - not has_arity(avp_arity(Name, F), '#get-'(F, Rec)), - {C,_,V} = H <- [avp_header(F)], - not maps:is_key({C,V}, Avps), - A <- [empty_avp(F,H)]]. + [{5005, empty_avp(F,H)} || {F,T} <- '#get-'(Rec), + not has_arity(avp_arity(Name, F), T), + {C,_,V} = H <- [avp_header(F)], + not maps:is_key({C,V}, Avps)]. %% Maximum arities have already been checked in building the record. @@ -232,8 +231,8 @@ has_prefix(0, _) -> true; has_prefix(_, []) -> false; -has_prefix(N, L) -> - has_prefix(N-1, tl(L)). +has_prefix(N, [_|L]) -> + has_prefix(N-1, L). %% empty_avp/2 |