aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/include
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2017-04-17 10:51:56 +0200
committerAnders Svensson <[email protected]>2017-06-12 16:13:52 +0200
commitf1a78f768414e97d30e72b1530475f2893fc75c5 (patch)
tree6f23e2587cd9b6564e7f642f53705a1a1c21bc1c /lib/diameter/include
parent8c975c3b325c6fa4926c1d12fba0b48e281a08cd (diff)
downloadotp-f1a78f768414e97d30e72b1530475f2893fc75c5.tar.gz
otp-f1a78f768414e97d30e72b1530475f2893fc75c5.tar.bz2
otp-f1a78f768414e97d30e72b1530475f2893fc75c5.zip
Don't create intermediate binaries unnecessarily during encode
Dict:avp(encode, Value, Name) no longer needs to return a binary, only an iolist(). Message encode runs list_to_binary/1 to convert accumulated lists into a message binary.
Diffstat (limited to 'lib/diameter/include')
-rw-r--r--lib/diameter/include/diameter_gen.hrl10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/diameter/include/diameter_gen.hrl b/lib/diameter/include/diameter_gen.hrl
index e745e3d2d3..e35d448754 100644
--- a/lib/diameter/include/diameter_gen.hrl
+++ b/lib/diameter/include/diameter_gen.hrl
@@ -75,7 +75,7 @@ eraser(K) ->
%% ---------------------------------------------------------------------------
-spec encode_avps(parent_name(), parent_record() | avp_values())
- -> binary()
+ -> iolist()
| no_return().
encode_avps(Name, Vals)
@@ -84,7 +84,7 @@ encode_avps(Name, Vals)
encode_avps(Name, Rec) ->
try
- list_to_binary(encode(Name, Rec))
+ encode(Name, Rec)
catch
throw: {?MODULE, Reason} ->
diameter_lib:log({encode, error},
@@ -655,7 +655,7 @@ value(_, Avp) ->
-spec grouped_avp(decode, avp_name(), bitstring())
-> {avp_record(), [avp()]};
(encode, avp_name(), avp_record() | avp_values())
- -> binary()
+ -> iolist()
| no_return().
%% Length error induced by diameter_codec:collect_avps/1: the AVP
@@ -719,10 +719,10 @@ z(Name, {Min, _}) ->
binary:copy(z(Name), Min).
z('AVP') ->
- <<0:64/integer>>; %% minimal header
+ <<0:64>>; %% minimal header
z(Name) ->
Bin = diameter_codec:pack_avp(avp_header(Name), empty_value(Name)),
- Sz = size(Bin),
+ Sz = iolist_size(Bin),
<<0:Sz/unit:8>>.
%% ---------------------------------------------------------------------------