unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Pip Cet <pipcet@gmail.com>
To: emacs-devel@gnu.org, Andrea Corallo <akrl@sdf.org>
Subject: Re: feature/native-comp ec88bdb 1/4: * Add a simple growable vector like type
Date: Wed, 24 Feb 2021 04:46:40 +0000	[thread overview]
Message-ID: <CAOqdjBcko9b+PH2LDdxBvuQDKqnWzDUbGW43fDX5d07N-wkzjA@mail.gmail.com> (raw)
In-Reply-To: <20210223232455.52DE320B76@vcs0.savannah.gnu.org>

On Tue, Feb 23, 2021 at 11:25 PM Andrea Corallo <akrl@savannah.gnu.org> wrote:
> +(defsubst comp-vec-length (vec)
> +  "Return the number of elements of VEC."
> +  (+ (comp-vec-beg vec) (comp-vec-end vec)))

Should this be (- (comp-vec-end vec) (comp-vec-beg vec))?

> +(defsubst comp-vec-append (vec elt)
> +  "Append ELT into VEC.
> +ELT is returned."
> +  (puthash (comp-vec-end vec) elt (comp-vec-aref vec))
> +  (cl-incf (comp-vec-end vec))
> +  elt)

I'd prefer, for aesthetic reasons, to have the incf first (increasing
the size of the vector), then puthashing elt at (1- (comp-vec-end
vec)).

Also, shouldn't the (comp-vec-aref vec) be a (comp-vec-data vec)?

(puthash (1- (incf (comp-vec-end vec))) elt (comp-vec-data vec))

> +(defsubst comp-vec-prepend (vec elt)
> +  "Prepend ELT into VEC.
> +ELT is returned."
> +  (puthash (comp-vec-beg vec) elt (comp-vec-aref vec))
> +  (cl-decf (comp-vec-beg vec))
> +  elt)

Does this need to decf first, then puthash?

(puthash (decf (comp-vec-beg vec)) elt (comp-vec-data vec)))



       reply	other threads:[~2021-02-24  4:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210223232452.24251.9558@vcs0.savannah.gnu.org>
     [not found] ` <20210223232455.52DE320B76@vcs0.savannah.gnu.org>
2021-02-24  4:46   ` Pip Cet [this message]
2021-02-25  5:41     ` feature/native-comp ec88bdb 1/4: * Add a simple growable vector like type Richard Stallman
2021-02-25  9:36       ` Pip Cet
2021-02-26  6:39         ` Richard Stallman
2021-02-26  9:10           ` Robert Pluim
2021-02-28  6:11             ` Richard Stallman
     [not found] ` <20210223232455.DB6F320536@vcs0.savannah.gnu.org>
2021-02-24  5:41   ` feature/native-comp bddd7a2 3/4: Do not emit assumptions referencing clobbered mvars (bug#46670) Pip Cet

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=CAOqdjBcko9b+PH2LDdxBvuQDKqnWzDUbGW43fDX5d07N-wkzjA@mail.gmail.com \
    --to=pipcet@gmail.com \
    --cc=akrl@sdf.org \
    --cc=emacs-devel@gnu.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).