[erlang-questions] naive execution of guards
Kostis Sagonas
kostis@REDACTED
Tue Dec 12 19:41:18 CET 2006
Ulf Wiger (TN/EAB) wrote:
> Kostis wrote:
>
>
>> Even some of the OTP code would benefit from it.
>>
> [...]
>> lib/megaco/src/text/megaco_text_parser_prev3a.hrl: when
>> length(Hex4) =< 4, length(Hex4) > 0 ->
>> lib/megaco/src/text/megaco_text_parser_prev3b.hrl: when
>> length(Hex4) =< 4, length(Hex4) > 0 ->
>> lib/megaco/src/text/megaco_text_parser_prev3c.hrl: when
>> length(Hex4) =< 4, length(Hex4) > 0 ->
> [...]
>
> It should perhaps also be noted that the megaco parser
> is highly performance-critical code, as are all parsers
> for these modern, text-based tele- and datacom protocols.
This of course is true, but these 3 cases are very easy to fix.
Instead of "length(Hex4) > 0" put a "[_|_] = Hex4" pattern matching
construct/constraint in the clause head.
Kostis
More information about the erlang-questions
mailing list