emacs-devel
[Top][All Lists]
Advanced

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

Re: [Emacs-diffs] master fe042e9: Speed up (+ 2 2) by a factor of 10


From: Pip Cet
Subject: Re: [Emacs-diffs] master fe042e9: Speed up (+ 2 2) by a factor of 10
Date: Tue, 4 Sep 2018 14:43:33 +0000

On Tue, Sep 4, 2018 at 1:50 AM Paul Eggert <address@hidden> wrote:
> diff --git a/src/fns.c b/src/fns.c
> index 17a869e..8b25492 100644
> --- a/src/fns.c
> +++ b/src/fns.c
> @@ -1468,19 +1468,17 @@ DEFUN ("nthcdr", Fnthcdr, Snthcdr, 2, 2, 0,
>        /* Undo any error introduced when LARGE_NUM was substituted for
>          N, by adding N - LARGE_NUM to NUM, using arithmetic modulo
>          CYCLE_LENGTH.  */
> -      mpz_t z; /* N mod CYCLE_LENGTH.  */
> -      mpz_init (z);
> +      /* Add N mod CYCLE_LENGTH to NUM.  */
>        if (cycle_length <= ULONG_MAX)
> -       num += mpz_mod_ui (z, XBIGNUM (n)->value, cycle_length);
> +       num += mpz_mod_ui (mpz[0], XBIGNUM (n)->value, cycle_length);

I think it would be best to use mpz_div_ui here (despite its name, it
returns the remainder of the division specified by its arguments).

Are you sure it wouldn't be possible to get the performance gains your
patch gives us without introducing global temporaries, such as by
using mpz_swap efficiently? Is this worth investigating, maybe, or do
you prefer global temporaries for another reason?



reply via email to

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