Subject: Re: bug#14769: [PATCH] optimize `concat's literals

From: Mattias Engdegård <[email-masked]>
Date: Wed, 19 Jun 2019 14:54:16 +0200

19 juni 2019 kl. 03.43 skrev Noam Postavsky <[email-masked]>:
> 
> Mattias Engdegård <[email-masked]> writes:
> 
>> +    (dolist (arg (cdr form))
> 
>> +                   (let ((val (eval arg)))
> 
>> +                          ;; Constant arg: concat with previous.
>> +                          (setq accum (concat accum val)))))
> 
> Hmm, I think the OP's patch is careful not to concat in a loop like
> this: it's O(n^2).  I guess for most human written code n is small
> enough that it doesn't matter, but I could imagine this slowing
> compilation of a very big rx macro.

Yes, I thought it wouldn't matter but you are right. Updated patch attached.

For that matter, ry performs this optimisation itself, but it's also nice to have it in the compiler, since concat is frequently used to split long string constants in elisp source.