diff options
author | Björn Gustavsson <[email protected]> | 2014-04-16 14:35:23 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2014-05-06 11:40:08 +0200 |
commit | 8eadd0297d9676a9004673f9efa2574283942f9f (patch) | |
tree | 503d6cc33bba0f4f2859bae5d017ff35359371d7 /lib/asn1/src/asn1rtt_ber.erl | |
parent | a86d63b3940c19dedb6ebcf0f684fa9641a9833e (diff) | |
download | otp-8eadd0297d9676a9004673f9efa2574283942f9f.tar.gz otp-8eadd0297d9676a9004673f9efa2574283942f9f.tar.bz2 otp-8eadd0297d9676a9004673f9efa2574283942f9f.zip |
BER: Optimize decoding of ENUMERATED
Diffstat (limited to 'lib/asn1/src/asn1rtt_ber.erl')
-rw-r--r-- | lib/asn1/src/asn1rtt_ber.erl | 41 |
1 files changed, 2 insertions, 39 deletions
diff --git a/lib/asn1/src/asn1rtt_ber.erl b/lib/asn1/src/asn1rtt_ber.erl index c65e7dea11..0c3c31e1d8 100644 --- a/lib/asn1/src/asn1rtt_ber.erl +++ b/lib/asn1/src/asn1rtt_ber.erl @@ -28,7 +28,7 @@ encode_integer/2,encode_integer/3, decode_integer/2, number2name/2, - encode_enumerated/2,decode_enumerated/3, + encode_enumerated/2, encode_unnamed_bit_string/2,encode_unnamed_bit_string/3, encode_named_bit_string/3,encode_named_bit_string/4, encode_bit_string/4, @@ -700,10 +700,7 @@ encode_integer_neg(N, Acc) -> %%=============================================================================== decode_integer(Tlv, TagIn) -> - V = match_tags(Tlv, TagIn), - decode_integer(V). - -decode_integer(Bin) -> + Bin = match_tags(Tlv, TagIn), Len = byte_size(Bin), <<Int:Len/signed-unit:8>> = Bin, Int. @@ -726,40 +723,6 @@ encode_enumerated(Val, TagIn) when is_integer(Val) -> encode_tags(TagIn, encode_integer(Val)). %%============================================================================ -%% decode enumerated value -%% (Buffer, Range, NamedNumberList, HasTag, TotalLen) -> Value -%%=========================================================================== -decode_enumerated(Tlv, NamedNumberList, Tags) -> - Buffer = match_tags(Tlv, Tags), - decode_enumerated_notag(Buffer, NamedNumberList, Tags). - -decode_enumerated_notag(Buffer, {NamedNumberList,ExtList}, _Tags) -> - IVal = decode_integer(Buffer), - case decode_enumerated1(IVal, NamedNumberList) of - {asn1_enum,IVal} -> - decode_enumerated1(IVal,ExtList); - EVal -> - EVal - end; -decode_enumerated_notag(Buffer, NNList, _Tags) -> - IVal = decode_integer(Buffer), - case decode_enumerated1(IVal, NNList) of - {asn1_enum,_} -> - exit({error,{asn1, {illegal_enumerated, IVal}}}); - EVal -> - EVal - end. - -decode_enumerated1(Val, NamedNumberList) -> - %% it must be a named integer - case lists:keyfind(Val, 2, NamedNumberList) of - {NamedVal, _} -> - NamedVal; - _ -> - {asn1_enum,Val} - end. - -%%============================================================================ %% Bitstring value, ITU_T X.690 Chapter 8.6 %% %% encode bitstring value |