[erlang-questions] split_binary simple question

Caoyuan dcaoyuan@REDACTED
Fri Jul 27 13:43:13 CEST 2007


Is there any difference between split_binary/2 and using binary match
to split it?

> B = <<48,49,50,51,52,53,54,55,56,57>>.
<<"0123456789">>
> {B1, B2} = split_binary(B,3).
{<<"012">>,<<"3456789">>}
> <<B3:3/binary, B4/binary>> = B.
<<"0123456789">>
> {B3, B4}.
{<<"012">>,<<"3456789">>}

I mean the implementation, efficiency, and GC behavior etc.

Thanks.

On 7/9/07, Ulf Wiger <ulf@REDACTED> wrote:
> No, you will get two references into the original binary.
>
> BR,
> Ulf W
>
> 2007/7/8, Mike McNally <m5@REDACTED>:
> > Does split_binary/2 make two new copies of the pieces of the binary
> > that's split? I would think not, but the documentation (which, it should
> > be noted, I have a history of misunderstanding) doesn't say explicitly.
> >
> >
> > --
> > [ I love pre-moistened towelettes ] Mike McNally -- m5@REDACTED
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://www.erlang.org/mailman/listinfo/erlang-questions
> >
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


-- 
- Caoyuan



More information about the erlang-questions mailing list