all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Tino Calancha <tino.calancha@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: [PATCH] ash, lsh: Avoid code duplication
Date: Mon, 21 Nov 2016 17:57:20 +0200	[thread overview]
Message-ID: <83k2bw9673.fsf@gnu.org> (raw)
In-Reply-To: <87inrg99in.fsf@gmail.com> (message from Tino Calancha on Mon, 21 Nov 2016 23:45:36 +0900)

> From: Tino Calancha <tino.calancha@gmail.com>
> Date: Mon, 21 Nov 2016 23:45:36 +0900
> Cc: tino.calancha@gmail.com
> 
> `ash' and `lsh' show some overlap.
> How about following patch?

With some more work (see below), and if no one objects, why not?

> +Lisp_Object
> +ash_lsh_impl (register Lisp_Object value, Lisp_Object count, int lsh)
                                                                ^^^^^^^
'bool', please.

Also, the function doesn't need to be extern, it should be static.

> -    XSETINT (val, XINT (value) < 0 ? -1 : 0);
> +    XSETINT (val, lsh == 1 ? 0 : XINT (value) < 0 ? -1 : 0);
                     ^^^^^^^^
a.k.a. "lsh ?"

> +DEFUN ("ash", Fash, Sash, 2, 2, 0,
> +       doc: /* Return VALUE with its bits shifted left by COUNT.
> +If COUNT is negative, shifting is actually to the right.
> +In this case, the sign bit is duplicated.  */)
> +  (register Lisp_Object value, Lisp_Object count)
> +{
> +  return ash_lsh_impl (value, count, 0);
                                        ^
'false', please.

> +  return ash_lsh_impl (value, count, 1);
                                        ^
'true', please.

> --- a/src/lisp.h
> +++ b/src/lisp.h
> @@ -602,6 +602,7 @@ extern void char_table_set (Lisp_Object, int, Lisp_Object);
>  /* Defined in data.c.  */
>  extern _Noreturn Lisp_Object wrong_type_argument (Lisp_Object, Lisp_Object);
>  extern _Noreturn void wrong_choice (Lisp_Object, Lisp_Object);
> +extern Lisp_Object ash_lsh_impl (Lisp_Object, Lisp_Object, int);

No need to make it extern, as no other C file uses it.



  reply	other threads:[~2016-11-21 15:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-21 14:45 [PATCH] ash, lsh: Avoid code duplication Tino Calancha
2016-11-21 15:57 ` Eli Zaretskii [this message]
2016-11-21 16:20   ` Tino Calancha
2016-11-21 17:14     ` Eli Zaretskii
2016-11-22  2:17       ` Tino Calancha
2016-11-22 16:12         ` Eli Zaretskii
2016-11-22 16:16           ` Tino Calancha
2016-11-27  3:28           ` Tino Calancha
2016-11-22 16:48       ` Davis Herring

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

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

  git send-email \
    --in-reply-to=83k2bw9673.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=tino.calancha@gmail.com \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.