emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mapc vs while


From: Stefan Monnier
Subject: Re: mapc vs while
Date: Thu, 23 Nov 2000 13:09:11 -0500

> Has somebody done some profiling on mapc vs while? Or is there any
> reason for mapc to be faster? 
> 
> I am refering to the fact that in the emacs sources there are a lot of
> code sequences like:
> 
> (setq first (car lst))
> (while first
>   (do-stuff-with-first
>   ... ...     
>       )
>   (setq first (car lst)))
> 
> Is it preferable to replace them with:
> 
> (mapc (lambda (x)
>       ... ...)
>       lst)

No.  Use `dolist'.  It currently turns into a `while', but if `mapc'
turns out to be faster, we could trivially change the macro to use `mapc'.

> Is there an official position on this? It would be nice to have a note
> about such usage in the NEWS file.

To me it only makes sense to use `mapc' if the function you're mapping
is already written or is not statically known.  But that's just coding
preferences, not something that should appear in the NEWS.


        Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]