aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/src/base
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2017-04-18 10:46:39 +0200
committerAnders Svensson <[email protected]>2017-06-12 16:13:52 +0200
commit0dd4fe49665a39a407764823ea3fabbc7bd8935b (patch)
tree9c1fa694b49252b1a6b05cb658dfe58434dd2430 /lib/diameter/src/base
parentc20f643e9539082f969a12f0a5513e543c5dad3e (diff)
downloadotp-0dd4fe49665a39a407764823ea3fabbc7bd8935b.tar.gz
otp-0dd4fe49665a39a407764823ea3fabbc7bd8935b.tar.bz2
otp-0dd4fe49665a39a407764823ea3fabbc7bd8935b.zip
Optimize sub binary creation
base/diameter_codec.erl:716: Warning: OPTIMIZED: creation of sub binary delayed
Diffstat (limited to 'lib/diameter/src/base')
-rw-r--r--lib/diameter/src/base/diameter_codec.erl17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/diameter/src/base/diameter_codec.erl b/lib/diameter/src/base/diameter_codec.erl
index ac74a1b9c1..90683e7329 100644
--- a/lib/diameter/src/base/diameter_codec.erl
+++ b/lib/diameter/src/base/diameter_codec.erl
@@ -703,20 +703,23 @@ pack_avp(#diameter_avp{code = undefined, data = B})
Len = size(<<H:5/binary, _:24, T/binary>> = <<B/binary, 0:Pad>>),
<<H/binary, Len:24, T/binary>>;
-%% ... when ignoring errors in Failed-AVP ...
-%% ... during a relay encode ...
-pack_avp(#diameter_avp{data = <<0:1, B/binary>>} = A) ->
- pack_data(B, A);
-
-%% ... or as an iolist.
pack_avp(#diameter_avp{data = Data} = A) ->
- pack_data(Data, A).
+ pack_bits(Data, A).
header_length(<<_:32, 1:1, _/bitstring>>) ->
12;
header_length(_) ->
8.
+%% pack_bits/2
+
+%% Ignoring errors in Failed-AVP or during a relay encode.
+pack_bits(<<0:1, B/binary>>, Avp) ->
+ pack_bits(B, Avp);
+
+pack_bits(Data, Avp) ->
+ pack_data(Data, Avp).
+
%% pack_data/2
pack_data(Data, #diameter_avp{code = Code,