OT? -NO! Essay: Programming as if Performance Mattered

Richard Carlsson <>
Fri May 7 11:34:18 CEST 2004


On Fri, 7 May 2004, Bjorn Gustavsson wrote:

> As James guessed in his article, code such as
>
>     "foo" ++ L
>
> is rewritten by the compiler to
>
>     [$f,$o,$o|L]
>
> while no similar optimization is done if you call lists:append/2.

Here's the fix (they are just different names for the same function).

===================================================================
RCS file:
lib/compiler/src/sys_core_fold.erl,v
retrieving revision 1.21
diff -u -r1.21 sys_core_fold.erl
--- lib/compiler/src/sys_core_fold.erl  28 Apr 2004 16:38:58 -0000
1.21
+++ lib/compiler/src/sys_core_fold.erl  7 May 2004 09:29:57 -0000
@@ -673,6 +673,8 @@
     fold_call_1(Call, M, F, Args);
 fold_call(Call, _M, _N, _Args) -> Call.

+fold_call_1(Call, lists, append, [Arg1,Arg2]) ->
+    eval_append(Call, Arg1, Arg2);
 fold_call_1(Call, erlang, length, [Arg]) ->
     eval_length(Call, Arg);
 fold_call_1(Call, erlang, '++', [Arg1,Arg2]) ->







Richard Carlsson ()   (This space intentionally left blank.)
E-mail: 	WWW: http://user.it.uu.se/~richardc/
 "Having users is like optimization: the wise course is to delay it."
   -- Paul Graham



More information about the erlang-questions mailing list