diff options
author | Anders Svensson <[email protected]> | 2017-04-18 10:46:39 +0200 |
---|---|---|
committer | Anders Svensson <[email protected]> | 2017-06-12 16:13:52 +0200 |
commit | 0dd4fe49665a39a407764823ea3fabbc7bd8935b (patch) | |
tree | 9c1fa694b49252b1a6b05cb658dfe58434dd2430 /lib/diameter/src/base | |
parent | c20f643e9539082f969a12f0a5513e543c5dad3e (diff) | |
download | otp-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.erl | 17 |
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, |