From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.devel Subject: Re: epg--status-GET-HIDDEN cleanup suggestion Date: Sat, 16 Aug 2008 11:05:32 -0500 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: References: <873al59iw9.fsf@broken.deisui.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1218902893 7145 80.91.229.12 (16 Aug 2008 16:08:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 16 Aug 2008 16:08:13 +0000 (UTC) Cc: Daiki Ueno To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Aug 16 18:09:06 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KUOKu-0004ho-W7 for ged-emacs-devel@m.gmane.org; Sat, 16 Aug 2008 18:09:05 +0200 Original-Received: from localhost ([127.0.0.1]:47050 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KUOJy-0005iO-B3 for ged-emacs-devel@m.gmane.org; Sat, 16 Aug 2008 12:08:06 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KUOHj-0003CV-UH for emacs-devel@gnu.org; Sat, 16 Aug 2008 12:05:48 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KUOHh-0003A8-W5 for emacs-devel@gnu.org; Sat, 16 Aug 2008 12:05:47 -0400 Original-Received: from [199.232.76.173] (port=43669 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KUOHh-00039w-QI for emacs-devel@gnu.org; Sat, 16 Aug 2008 12:05:45 -0400 Original-Received: from main.gmane.org ([80.91.229.2]:47564 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KUOHh-0004QM-6S for emacs-devel@gnu.org; Sat, 16 Aug 2008 12:05:45 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1KUOHc-00075i-F3 for emacs-devel@gnu.org; Sat, 16 Aug 2008 16:05:40 +0000 Original-Received: from c-68-60-254-123.hsd1.il.comcast.net ([68.60.254.123]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 16 Aug 2008 16:05:40 +0000 Original-Received: from tzz by c-68-60-254-123.hsd1.il.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 16 Aug 2008 16:05:40 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 44 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: c-68-60-254-123.hsd1.il.comcast.net X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6; d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (darwin) Cancel-Lock: sha1:eDdQ2INL9KWtlfitQNPkR3mSDKI= X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:102533 Archived-At: On Sat, 16 Aug 2008 22:41:42 +0900 Daiki Ueno wrote: DU> Ted Zlatanov writes: >> The function epg--status-GET-HIDDEN in epg.el had lots of repetition, so >> I cleaned it up a little with a let*. DU> Lots of? It seems that your change binds only a few variables, and DU> doesn't reduce the lines of code. You called (epg-context-passphrase-callback context) 6 times. My change reduces it to 1 call, bound to a variable from that point on. Also, I changed (funcall (if (consp (epg-context-passphrase-callback context)) (car (epg-context-passphrase-callback context)) (epg-context-passphrase-callback context)) context epg-key-id (if (consp (epg-context-passphrase-callback context)) (cdr (epg-context-passphrase-callback context)))) to (let* ((context-callback (epg-context-passphrase-callback context)) (callback (or (car-safe context-callback) context-callback)) (file (cdr-safe context-callback))) ... (funcall callback context epg-key-id file)) which to me seems much more readable (using car-safe and cdr-safe makes the logic simpler too). Lines of code are not the only measure of code cleanliness; in this specific case I found your logic hard to read while debugging an unrelated problem so I tried to clean it up. >> I don't know the protocol for comitting these cleanups, so I offer the >> patch for review. It works for me. DU> I don't like to bind variables which is used only once at run time. Your choice, it's your code. I find my version more readable, but that's certainly a matter of opinion. Ted