bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#15149: 24.3; [PATCH] compute calendar-chinese-year-cache lazily


From: Glenn Morris
Subject: bug#15149: 24.3; [PATCH] compute calendar-chinese-year-cache lazily
Date: Wed, 21 Aug 2013 12:04:34 -0400
User-agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)

Leo Liu wrote:

> Seems a lot of hassle to manually maintain a cache 

It's been no hassle.

> and the computation is reasonable fast (it takes 0.5 seconds on my
> Core 2 Duo 2G laptop). So I propose this patch.

Probably precomputing serves little purpose in this day and age, and
could just as well be removed. But since it is causing no problems, I
don't see too much point.

>  (defun calendar-chinese-year (y)
>    "The structure of the Chinese year for Gregorian year Y.
> @@ -386,6 +330,12 @@
>  of the Chinese months from the Chinese month following the solstice in
>  Gregorian year Y-1 to the Chinese month of the solstice of Gregorian year Y.
>  The list is cached in `calendar-chinese-year-cache' for further use."
> +  (or calendar-chinese-year-cache
> +      (setq calendar-chinese-year-cache
> +            (mapcar (lambda (y)
> +                      (cons y (calendar-chinese-compute-year y)))
> +                    (let ((year (nth 5 (decode-time))))
> +                      (number-sequence (- year 10) (+ year 10))))))

I don't see the point of this. It makes the first call you make ~ 20
times slower, in order to compute a bunch of values that might well have
no relevance to that call or any other.





reply via email to

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