Jean Abou Samra <j...@abou-samra.fr> writes:

> Le mardi 08 août 2023 à 19:53 +0200, Lukas-Fabian Moser a écrit :
>> Yes, sure, that's what I did in my code for Alasdair. But I was more 
>> wondering whether or not RhythmicStaves (RhythmicStaff's?) should do 
>> this automatically.
>> 
>> By the way, I didn't know about music-clone. What's its advantage over 
>> ly:music-deep-copy?
>
> As far as I understand the docstring,
>
> (music-clone mus 'elements new-elts)
>
> is more efficient than
>
> (let ((new-mus (ly:music-deep-copy mus)))
>   (ly:music-set-property! new-mus 'elements new-elts)
>   new-mus)
>
> because it will avoid deeply copying the elements list and
> all its elements, by noticing that it will be overridden
> by new-elts anyway.

Given that ly:music-deep-copy is written in C++, I doubt better
efficiency.

> Without extra arguments, (music-clone m) should be strictly
> equivalent to (ly:music-deep-copy m).

The extra arguments are different, and, well, it is shorter to write.

-- 
David Kastrup

Reply via email to