aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1
diff options
context:
space:
mode:
authorGustav Simonsson <[email protected]>2012-07-03 17:17:00 +0200
committerGustav Simonsson <[email protected]>2012-07-03 17:17:00 +0200
commit49a4c58106ca913328b5f28e7124e820b15e4b43 (patch)
tree2cf8eb08069d673673e01810b529cf68ed336ccb /lib/asn1
parent5fdcb7a097a3956ebf52c24721c91f60aeb96aa1 (diff)
downloadotp-49a4c58106ca913328b5f28e7124e820b15e4b43.tar.gz
otp-49a4c58106ca913328b5f28e7124e820b15e4b43.tar.bz2
otp-49a4c58106ca913328b5f28e7124e820b15e4b43.zip
Keep encoded octets of constrained whole number value and
range as binaries and use erlang:byte_size to get length of octets and range. For speed.
Diffstat (limited to 'lib/asn1')
-rw-r--r--lib/asn1/src/asn1rt_per_bin.erl8
-rw-r--r--lib/asn1/src/asn1rt_per_bin_rt2ct.erl8
2 files changed, 8 insertions, 8 deletions
diff --git a/lib/asn1/src/asn1rt_per_bin.erl b/lib/asn1/src/asn1rt_per_bin.erl
index 4e0c12936c..85988aa21d 100644
--- a/lib/asn1/src/asn1rt_per_bin.erl
+++ b/lib/asn1/src/asn1rt_per_bin.erl
@@ -695,10 +695,10 @@ encode_constrained_number({Lb,Ub},Val) when Val >= Lb, Ub >= Val ->
Range =< 65536 ->
{octets,<<Val2:16>>};
Range =< (1 bsl (255*8)) ->
- Octs = binary:bin_to_list(binary:encode_unsigned(Val2)),
- RangeOcts = binary:bin_to_list(binary:encode_unsigned(Range - 1)),
- OctsLen = length(Octs),
- RangeOctsLen = length(RangeOcts),
+ Octs = binary:encode_unsigned(Val2),
+ RangeOcts = binary:encode_unsigned(Range - 1),
+ OctsLen = erlang:byte_size(Octs),
+ RangeOctsLen = erlang:byte_size(RangeOcts),
LengthBitsNeeded = minimum_bits(RangeOctsLen - 1),
[{bits, LengthBitsNeeded, OctsLen - 1}, {octets, Octs}];
true ->
diff --git a/lib/asn1/src/asn1rt_per_bin_rt2ct.erl b/lib/asn1/src/asn1rt_per_bin_rt2ct.erl
index f2e93cf096..46d4bcb065 100644
--- a/lib/asn1/src/asn1rt_per_bin_rt2ct.erl
+++ b/lib/asn1/src/asn1rt_per_bin_rt2ct.erl
@@ -605,10 +605,10 @@ encode_constrained_number({Lb,Ub},Val) when Val >= Lb, Ub >= Val ->
% Size = {octets,<<Val2:16>>};
[20,2,<<Val2:16>>];
Range =< (1 bsl (255*8)) ->
- Octs = binary:bin_to_list(binary:encode_unsigned(Val2)),
- RangeOcts = binary:bin_to_list(binary:encode_unsigned(Range - 1)),
- OctsLen = length(Octs),
- RangeOctsLen = length(RangeOcts),
+ Octs = binary:encode_unsigned(Val2),
+ RangeOcts = binary:encode_unsigned(Range - 1),
+ OctsLen = erlang:byte_size(Octs),
+ RangeOctsLen = erlang:byte_size(RangeOcts),
LengthBitsNeeded = asn1rt_per_bin:minimum_bits(RangeOctsLen - 1),
[10,LengthBitsNeeded,OctsLen-1,20,OctsLen,Octs];
true ->