[erlang-questions] Which is best? string:concat or ++?

Paul Davis paul.joseph.davis@REDACTED
Mon May 7 15:37:13 CEST 2012


Quick scan of the source shows that string:concat/2 is exactly the ++
operator. So using ++ will save you a function invocation assuming the
Erlang compiler doesn't optimize that away.

https://github.com/erlang/otp/blob/maint/lib/stdlib/src/string.erl#L61

On Mon, May 7, 2012 at 8:31 AM, Paul Barry <paul.james.barry@REDACTED> wrote:
> Hi folks.
>
> This might be a case of a dumb question, but here goes anyway.  :-)
>
> I have two strings, A and B.  Is it better to use:
>
>   string:concat(A, B)
>
> or
>
>    A ++ B
>
> when combining them to create a new string?  I'm writing some code
> that generates a chunk of HTML.  I know that using ++ on big lists is
> regarded as a "no-no", but is it acceptable here?
>
> Thanks.
>
> Paul.
>
> --
> Paul Barry, w: http://paulbarry.itcarlow.ie - e: paul.barry@REDACTED
> Lecturer, Computer Networking: Institute of Technology, Carlow, Ireland.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list