From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Glenn Morris Newsgroups: gmane.emacs.bugs Subject: bug#15149: 24.3; [PATCH] compute calendar-chinese-year-cache lazily Date: Wed, 21 Aug 2013 12:04:34 -0400 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1377101111 21663 80.91.229.3 (21 Aug 2013 16:05:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 21 Aug 2013 16:05:11 +0000 (UTC) Cc: 15149@debbugs.gnu.org To: Leo Liu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Aug 21 18:05:13 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VCAuH-0000uQ-8T for geb-bug-gnu-emacs@m.gmane.org; Wed, 21 Aug 2013 18:05:13 +0200 Original-Received: from localhost ([::1]:54773 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VCAuG-00052k-Rq for geb-bug-gnu-emacs@m.gmane.org; Wed, 21 Aug 2013 12:05:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55297) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VCAu9-0004xe-4E for bug-gnu-emacs@gnu.org; Wed, 21 Aug 2013 12:05:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VCAu7-0004zp-OP for bug-gnu-emacs@gnu.org; Wed, 21 Aug 2013 12:05:05 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:50846) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VCAu7-0004zh-LQ for bug-gnu-emacs@gnu.org; Wed, 21 Aug 2013 12:05:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VCAu6-00078P-2a for bug-gnu-emacs@gnu.org; Wed, 21 Aug 2013 12:05:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Glenn Morris Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 21 Aug 2013 16:05:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15149 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 15149-submit@debbugs.gnu.org id=B15149.137710107827393 (code B ref 15149); Wed, 21 Aug 2013 16:05:01 +0000 Original-Received: (at 15149) by debbugs.gnu.org; 21 Aug 2013 16:04:38 +0000 Original-Received: from localhost ([127.0.0.1]:45162 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VCAth-00077j-AO for submit@debbugs.gnu.org; Wed, 21 Aug 2013 12:04:37 -0400 Original-Received: from fencepost.gnu.org ([208.118.235.10]:39659) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VCAtf-00077b-1e for 15149@debbugs.gnu.org; Wed, 21 Aug 2013 12:04:35 -0400 Original-Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1VCAte-0003xb-6s; Wed, 21 Aug 2013 12:04:34 -0400 X-Spook: InfoSec government secure domestic disruption Leitrim X-Ran: Xnc^1D(D4ay%fZ:T\rd[2RHHp-II)Dr7=nZvL&@QX|n1J;OmZm)"/JU_Z/$Buk/28~eu(D X-Hue: red X-Attribution: GM User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:77583 Archived-At: 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.