Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@ericsson.com>
To: Tom Tromey <tom@tromey.com>, <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Remove some uses VEC from parsers
Date: Mon, 27 Aug 2018 21:35:00 -0000	[thread overview]
Message-ID: <2a9d9432-3bd3-f4c7-0817-dbf6ad7d655d@ericsson.com> (raw)
In-Reply-To: <20180827211901.20992-1-tom@tromey.com>

On 2018-08-27 05:19 PM, Tom Tromey wrote:
> diff --git a/gdb/go-exp.y b/gdb/go-exp.y
> index 47570d59111..a2436145491 100644
> --- a/gdb/go-exp.y
> +++ b/gdb/go-exp.y
> @@ -1279,17 +1279,15 @@ lex_one_token (struct parser_state *par_state)
>  }
>  
>  /* An object of this type is pushed on a FIFO by the "outer" lexer.  */
> -typedef struct
> +struct token_and_value
>  {
>    int token;
>    YYSTYPE value;
> -} token_and_value;
> -
> -DEF_VEC_O (token_and_value);
> +};
>  
>  /* A FIFO of tokens that have been read but not yet returned to the
>     parser.  */
> -static VEC (token_and_value) *token_fifo;
> +static std::vector<token_and_value> token_fifo;
>  
>  /* Non-zero if the lexer should return tokens from the FIFO.  */
>  static int popping;
> @@ -1485,10 +1483,10 @@ yylex (void)
>  {
>    token_and_value current, next;
>  
> -  if (popping && !VEC_empty (token_and_value, token_fifo))
> +  if (popping && !token_fifo.empty ())
>      {
> -      token_and_value tv = *VEC_index (token_and_value, token_fifo, 0);
> -      VEC_ordered_remove (token_and_value, token_fifo, 0);
> +      token_and_value tv = token_fifo[0];
> +      token_fifo.erase (token_fifo.begin ());
>        yylval = tv.value;
>        /* There's no need to fall through to handle package.name
>  	 as that can never happen here.  In theory.  */
> @@ -1541,12 +1539,12 @@ yylex (void)
>  	    }
>  	}
>  
> -      VEC_safe_push (token_and_value, token_fifo, &next);
> -      VEC_safe_push (token_and_value, token_fifo, &name2);
> +      token_fifo.push_back (next);
> +      token_fifo.push_back (name2);
>      }
>    else
>      {
> -      VEC_safe_push (token_and_value, token_fifo, &next);
> +      token_fifo.push_back (next);
>      }

Can you remove the extra braces, while at it?

LGTM, thanks!

Simon


  reply	other threads:[~2018-08-27 21:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-27 21:19 Tom Tromey
2018-08-27 21:35 ` Simon Marchi [this message]
2018-08-28 17:35   ` Tom Tromey

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=2a9d9432-3bd3-f4c7-0817-dbf6ad7d655d@ericsson.com \
    --to=simon.marchi@ericsson.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox