aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2014-12-05 07:48:26 +0100
committerBjörn Gustavsson <[email protected]>2015-01-12 12:22:57 +0100
commite96b4bbb802cd00fa14deb12d7200873c7a79e85 (patch)
treed65e90c80a01fc6288eaae59e08ed143c2d65bbc /lib/asn1/src
parent7129f2acb474651fa4ef922b24ff18dd84dd9c77 (diff)
downloadotp-e96b4bbb802cd00fa14deb12d7200873c7a79e85.tar.gz
otp-e96b4bbb802cd00fa14deb12d7200873c7a79e85.tar.bz2
otp-e96b4bbb802cd00fa14deb12d7200873c7a79e85.zip
asn1ct_parser2: Remove expensive lookahead_assignment/1 function
In the parsing of a value assignment, such as: value INTEGER ::= 42 there is call to a function called lookahead_assignment/1 that will ensure that the sequence of tokens that follows the value is a valid assignment. The problem is that if the next assignment is a value assignment, that too will look ahead to the next assignment. That means that the complexity will be quadratic if there are many value assignments following each other. The reason for the test in the first place is unclear; my guess is that it was an attempt to provide better error reporting.
Diffstat (limited to 'lib/asn1/src')
-rw-r--r--lib/asn1/src/asn1ct_parser2.erl10
1 files changed, 0 insertions, 10 deletions
diff --git a/lib/asn1/src/asn1ct_parser2.erl b/lib/asn1/src/asn1ct_parser2.erl
index 7a1c7230b3..488e4af4e0 100644
--- a/lib/asn1/src/asn1ct_parser2.erl
+++ b/lib/asn1/src/asn1ct_parser2.erl
@@ -2133,7 +2133,6 @@ parse_ValueAssignment([#identifier{pos=L1,val=IdName}|Rest]) ->
case Rest2 of
[{'::=',_}|Rest3] ->
{Value,Rest4} = parse_Value(Rest3),
- lookahead_assignment(Rest4),
{#valuedef{pos=L1,name=IdName,type=Type,value=Value,
module=get(asn1_module)},Rest4};
_ ->
@@ -2300,14 +2299,5 @@ identifier2Extvalueref(#identifier{pos=Pos,val=Name}) ->
module=resolve_module(Name),
value=Name}.
-%% lookahead_assignment/1 checks that the next sequence of tokens
-%% in Token contain a valid assignment or the
-%% 'END' token. Otherwise an exception is thrown.
-lookahead_assignment([{'END',_}|_Rest]) ->
- ok;
-lookahead_assignment(Tokens) ->
- {_,_} = parse_Assignment(Tokens),
- ok.
-
parse_error(Tokens) ->
throw({asn1_error,{parse_error,Tokens}}).