aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src/asn1rtt_real_common.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2013-05-28 06:49:38 +0200
committerBjörn Gustavsson <[email protected]>2013-08-30 10:13:16 +0200
commit060bd359237cdb629abba03620323c0ed8084910 (patch)
tree77131a0c11a899ec9c3d13a691edbeb68b181596 /lib/asn1/src/asn1rtt_real_common.erl
parentb2b81e94855075c8e7cbd7f61d62900914d72222 (diff)
downloadotp-060bd359237cdb629abba03620323c0ed8084910.tar.gz
otp-060bd359237cdb629abba03620323c0ed8084910.tar.bz2
otp-060bd359237cdb629abba03620323c0ed8084910.zip
Refactor encoding of REAL
To facilitate optimizing PER encoding using an intermediate format, we must change asn1rtt_real_common:encode_real/1 so that it only returns the encoded binary.
Diffstat (limited to 'lib/asn1/src/asn1rtt_real_common.erl')
-rw-r--r--lib/asn1/src/asn1rtt_real_common.erl6
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/asn1/src/asn1rtt_real_common.erl b/lib/asn1/src/asn1rtt_real_common.erl
index 22a1f4c4dd..12ca165ecd 100644
--- a/lib/asn1/src/asn1rtt_real_common.erl
+++ b/lib/asn1/src/asn1rtt_real_common.erl
@@ -105,8 +105,7 @@ encode_real(_C, {Mantissa, Base, Exponent}) when Base =:= 2 ->
true -> list_to_binary(real_mininum_octets(-(Man))) % signbit keeps track of sign
end,
%% ok = io:format("LenMask: ~w EOctets: ~w~nFirstOctet: ~w OctMantissa: ~w OctExpLen: ~w~n", [LenMask, EOctets, FirstOctet, OctMantissa, OctExpLen]),
- Bin = <<FirstOctet/binary, EOctets/binary, OctMantissa/binary>>,
- {Bin, size(Bin)};
+ <<FirstOctet/binary, EOctets/binary, OctMantissa/binary>>;
encode_real(C, {Mantissa,Base,Exponent})
when Base =:= 10, is_integer(Mantissa), is_integer(Exponent) ->
%% always encode as NR3 due to DER on the format
@@ -176,8 +175,7 @@ encode_real_as_string(_C, Mantissa, Exponent)
end,
ManBin = list_to_binary(TruncMant),
NR3 = 3,
- {<<NR3,ManBin/binary,$.,ExpBin/binary>>,
- 2 + byte_size(ManBin) + byte_size(ExpBin)}.
+ <<NR3,ManBin/binary,$.,ExpBin/binary>>.
remove_trailing_zeros(IntStr) ->
case lists:dropwhile(fun($0)-> true;