Subject: Re: [erlang-questions] binary match vs. is_binary
in optimization

t1 doesn't extract a sub-binary from your binary, so there's nothing to optimize.
2017-08-02 19:35 GMT+03:00 Andreas Schultz <[email protected]>:

Can someone explain why the binary optimization treats a is_binary()
guard different that an binary match?

I the attached test code, I get a:

> test.erl:7: Warning: NOT OPTIMIZED: called function t1/1 does not begin with a suitable binary matching instruction

and a

> test.erl:14: Warning: OPTIMIZED: creation of sub binary delayed

for the second function. IMHO both should be identical, but apparently they are not.

Many thanks,

Test code:




do(<<Bin/binary>>) ->

t1(Bin) when is_binary(Bin) ->
    test(Bin, []).

t3(<<Bin/binary>>) ->
    test(Bin, []).

test(<<X:4/integer, _/binary>>, _) ->
Dipl.-Inform. Andreas Schultz

email: [email protected]
phone: +49-391-819099-224

----------------------- enabling your networks ----------------------

Travelping GmbH                     phone:  +49-391-81 90 99 0
Roentgenstr.  13                    fax:    +49-391-81 90 99 299
39108 Magdeburg                     email:  [email protected]
GERMANY                             web:" rel="noreferrer" target="_blank">

Company Registration: Amtsgericht Stendal        Reg No.:   HRB 10578
Geschaeftsfuehrer: Holger Winkelmann          VAT ID No.: DE236673780
erlang-questions mailing list
[email protected]

erlang-questions mailing list
[email protected]

Programming list archiving by: Enterprise Git Hosting