The Erlang compiler is quite smart when compiling patterns but there are some things which are extremely difficult to optimise. So it can be really smart with atoms, integers, tuples and lists. However strings, and binaries which is how they are implemented, are much more difficult; in many cases it can’t do better then testing them sequentially which is why you can get some improvement by reordering them. This is a case where lists strings can be more efficient. ![]()
So in your example it can group all the clauses and only do the list checking and extracting only once it still needs to test the strings sequentially.
Note that while the pattern matching compiler may choose to reorder clauses and checking it will semantically always behave as if it is done sequentially.






















