[erlang-questions] idea: service pack one

Bjorn Gustavsson bjorn@REDACTED
Thu Nov 15 13:41:00 CET 2007

Joel Reymont <joelr1@REDACTED> writes:

> The difference seems to be in matching an empty binary vs <<_Head:N/
> binary>>.
> Why exactly is the 2nd pattern so much faster?

The first pattern (<<>>) does not match. That was worked around (by the original
author) by adding the following clause:

index(Str, _Char, N) when N > size(Str) ->

What I did what to make sure that the pattern could match (<<_Head:N/binary>>),
and comment out the now redundant second clause.

Björn Gustavsson, Erlang/OTP, Ericsson AB

More information about the erlang-questions mailing list