unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Ted Zlatanov <tzz@lifelogs.com>
To: emacs-devel@gnu.org
Cc: Daiki Ueno <ueno@unixuser.org>
Subject: Re: epg--status-GET-HIDDEN cleanup suggestion
Date: Sat, 16 Aug 2008 11:05:32 -0500	[thread overview]
Message-ID: <m2skt53pyr.fsf@lifelogs.com> (raw)
In-Reply-To: 873al59iw9.fsf@broken.deisui.org

On Sat, 16 Aug 2008 22:41:42 +0900 Daiki Ueno <ueno@unixuser.org> wrote: 

DU> Ted Zlatanov <tzz@lifelogs.com> 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





  reply	other threads:[~2008-08-16 16:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-16 13:17 epg--status-GET-HIDDEN cleanup suggestion Ted Zlatanov
2008-08-16 13:41 ` Daiki Ueno
2008-08-16 16:05   ` Ted Zlatanov [this message]
2008-08-18  1:16     ` Daiki Ueno

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2skt53pyr.fsf@lifelogs.com \
    --to=tzz@lifelogs.com \
    --cc=emacs-devel@gnu.org \
    --cc=ueno@unixuser.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).