From e96b4bbb802cd00fa14deb12d7200873c7a79e85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Fri, 5 Dec 2014 07:48:26 +0100 Subject: 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. --- lib/asn1/src/asn1ct_parser2.erl | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'lib/asn1/src/asn1ct_parser2.erl') 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}}). -- cgit v1.2.3