aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2013-07-01 22:40:33 +0200
committerBjörn Gustavsson <[email protected]>2013-08-30 10:13:17 +0200
commitc0fce14273c4933cc1af8006c3975cfabd2ad0ad (patch)
treec3e54ce2f7c887537654d543a428a8f776574bb2 /lib/asn1/src
parent6b4c51b72dd5b17c26c624f09e88e038d7edfcb5 (diff)
downloadotp-c0fce14273c4933cc1af8006c3975cfabd2ad0ad.tar.gz
otp-c0fce14273c4933cc1af8006c3975cfabd2ad0ad.tar.bz2
otp-c0fce14273c4933cc1af8006c3975cfabd2ad0ad.zip
UPER: Optimize complete/1
Diffstat (limited to 'lib/asn1/src')
-rw-r--r--lib/asn1/src/asn1rtt_uper.erl15
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/asn1/src/asn1rtt_uper.erl b/lib/asn1/src/asn1rtt_uper.erl
index a5035c6660..a08f7028dc 100644
--- a/lib/asn1/src/asn1rtt_uper.erl
+++ b/lib/asn1/src/asn1rtt_uper.erl
@@ -935,13 +935,14 @@ get_constraint(C,Key) ->
%% Should be applied as the last step at encode of a complete ASN.1 type
%%
complete(InList) when is_list(InList) ->
- case complete1(InList) of
+ case list_to_bitstring(InList) of
<<>> ->
<<0>>;
Res ->
- case bit_size(Res) band 7 of
+ Sz = bit_size(Res),
+ case Sz band 7 of
0 -> Res;
- Bits -> <<Res/bitstring,0:(8-Bits)>>
+ Bits -> <<Res:Sz/bitstring,0:(8-Bits)>>
end
end;
complete(Bin) when is_binary(Bin) ->
@@ -950,11 +951,9 @@ complete(Bin) when is_binary(Bin) ->
_ -> Bin
end;
complete(InList) when is_bitstring(InList) ->
- PadLen = 8 - (bit_size(InList) band 7),
- <<InList/bitstring,0:PadLen>>.
-
-complete1(L) when is_list(L) ->
- list_to_bitstring(L).
+ Sz = bit_size(InList),
+ PadLen = 8 - (Sz band 7),
+ <<InList:Sz/bitstring,0:PadLen>>.
%% Special version of complete that does not align the completed message.
complete_NFP(InList) when is_list(InList) ->