[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [External] : Use of an associated list with completing-read
From: |
Drew Adams |
Subject: |
RE: [External] : Use of an associated list with completing-read |
Date: |
Sat, 20 Apr 2024 01:13:12 +0000 |
> > (setq-local tema-lugar
> > (append tema--lugar (list (cons lnum strg))))
>
> This is the classic recipe for poor scaling performance since the above
> operation takes time proportional to the length of the list, so if you
> execute this N times (in a loop), the loop builds a list of length N
> but takes time N² to do it. When N is small, noone notices, and as it gets
> large the performance starts to suck.
Heime:
One programming cliche for this is to
(1) start with a list that you create
(e.g., a let-binding to nil), so you
don't modify any existing list that
you might not want to mess with, (2)
use `nconc' instead of `append', to
append quickly (the _list structure_
is modified - destructive), (3) being
sure to set your list variable to the
result of each modification.
An even more common cliche for doing
the same thing is to do #1, then (2)
cons instead of append, and (3) when
finished adding list elements, do an
`nreverse' of the list you created.
That too is a destructive operation.
<<attachment: winmail.dat>>
- Use of an associated list with completing-read, Heime, 2024/04/18
- RE: [External] : Use of an associated list with completing-read, Drew Adams, 2024/04/18
- RE: [External] : Use of an associated list with completing-read, Heime, 2024/04/18
- RE: [External] : Use of an associated list with completing-read, Heime, 2024/04/18
- RE: [External] : Use of an associated list with completing-read, Drew Adams, 2024/04/19
- RE: [External] : Use of an associated list with completing-read, Heime, 2024/04/19
- Re: [External] : Use of an associated list with completing-read, Stefan Monnier, 2024/04/19
- RE: [External] : Use of an associated list with completing-read,
Drew Adams <=
- Re: [External] : Use of an associated list with completing-read, Stefan Monnier, 2024/04/19
- Re: [External] : Use of an associated list with completing-read, Heime, 2024/04/20
- Re: [External] : Use of an associated list with completing-read, Heime, 2024/04/20
- Re: [External] : Use of an associated list with completing-read, Emanuel Berg, 2024/04/20
Re: Use of an associated list with completing-read, Jean Louis, 2024/04/23