<div dir="ltr">t1 doesn't extract a sub-binary from your binary, so there's nothing to optimize.</div><div class="gmail_extra"><br><div class="gmail_quote">2017-08-02 19:35 GMT+03:00 Andreas Schultz <span dir="ltr"><<a href="mailto:aschultz@tpip.net" target="_blank">aschultz@tpip.net</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
Can someone explain why the binary optimization treats a is_binary()<br>
guard different that an binary match?<br>
<br>
I the attached test code, I get a:<br>
<br>
> test.erl:7: Warning: NOT OPTIMIZED: called function t1/1 does not begin with a suitable binary matching instruction<br>
<br>
and a<br>
<br>
> test.erl:14: Warning: OPTIMIZED: creation of sub binary delayed<br>
<br>
for the second function. IMHO both should be identical, but apparently they are not.<br>
<br>
Many thanks,<br>
Andreas<br>
<br>
Test code:<br>
<br>
-module(test).<br>
<br>
-compile([bin_opt_info]).<br>
<br>
-export([do/1]).<br>
<br>
do(<<Bin/binary>>) -><br>
t1(Bin),<br>
t3(Bin).<br>
<br>
t1(Bin) when is_binary(Bin) -><br>
test(Bin, []).<br>
<br>
t3(<<Bin/binary>>) -><br>
test(Bin, []).<br>
<br>
test(<<X:4/integer, _/binary>>, _) -><br>
X.<br>
--<br>
Dipl.-Inform. Andreas Schultz<br>
<br>
email: <a href="mailto:as@travelping.com">as@travelping.com</a><br>
phone: +49-391-819099-224<br>
<br>
----------------------- enabling your networks ----------------------<br>
<br>
Travelping GmbH phone: +49-391-81 90 99 0<br>
Roentgenstr. 13 fax: +49-391-81 90 99 299<br>
39108 Magdeburg email: <a href="mailto:info@travelping.com">info@travelping.com</a><br>
GERMANY web: <a href="http://www.travelping.com" rel="noreferrer" target="_blank">http://www.travelping.com</a><br>
<br>
Company Registration: Amtsgericht Stendal Reg No.: HRB 10578<br>
Geschaeftsfuehrer: Holger Winkelmann VAT ID No.: DE236673780<br>
------------------------------<wbr>------------------------------<wbr>---------<br>
______________________________<wbr>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/<wbr>listinfo/erlang-questions</a><br>
</blockquote></div><br></div>