aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2015-07-07 09:58:21 +0200
committerAnders Svensson <[email protected]>2015-08-04 17:33:37 +0200
commit16aaa29b7ce40596520d563b6f4a8e0aeba7b085 (patch)
tree734c30ca2279c5e927552c14be611a2090d91b4b /lib/diameter
parentabd6c7494f973eb91c6a582f3370e9896d28992b (diff)
downloadotp-16aaa29b7ce40596520d563b6f4a8e0aeba7b085.tar.gz
otp-16aaa29b7ce40596520d563b6f4a8e0aeba7b085.tar.bz2
otp-16aaa29b7ce40596520d563b6f4a8e0aeba7b085.zip
Don't traverse errors list unnecessarily when detecting missing AVPs
Since the list can potentially be long.
Diffstat (limited to 'lib/diameter')
-rw-r--r--lib/diameter/include/diameter_gen.hrl23
1 files changed, 11 insertions, 12 deletions
diff --git a/lib/diameter/include/diameter_gen.hrl b/lib/diameter/include/diameter_gen.hrl
index 0b36389088..79b8e6ecde 100644
--- a/lib/diameter/include/diameter_gen.hrl
+++ b/lib/diameter/include/diameter_gen.hrl
@@ -201,20 +201,19 @@ newrec(Name) ->
%% Failed-AVP AVP SHOULD be included in the message. The Failed-AVP
%% AVP MUST contain an example of the missing AVP complete with the
%% Vendor-Id if applicable. The value field of the missing AVP
-%% should be of correct minimum length and contain zeroes.
+%% should be of correct minimum length and contain zeros.
missing(Rec, Name, Failed) ->
- [{5005, A} || #diameter_avp{code = MC, vendor_id = MV} = A
- <- missing(Rec, Name),
- lists:all(fun({_, #diameter_avp{code = C, vendor_id = V}}) ->
- MC /= C orelse MV /= V
- end,
- Failed)].
-
-missing(Rec, Name) ->
- [empty_avp(F) || F <- '#info-'(element(1, Rec), fields),
- A <- [avp_arity(Name, F)],
- not have_arity(A, '#get-'(F, Rec))].
+ Avps = lists:foldl(fun({_, #diameter_avp{code = C, vendor_id = V}}, A) ->
+ sets:add_element({C,V}, A)
+ end,
+ sets:new(),
+ Failed),
+ [{5005, A} || F <- '#info-'(element(1, Rec), fields),
+ not have_arity(avp_arity(Name, F), '#get-'(F, Rec)),
+ #diameter_avp{code = C, vendor_id = V}
+ = A <- [empty_avp(F)],
+ not sets:is_element({C,V}, Avps)].
%% Maximum arities have already been checked in building the record.