From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31785 invoked by alias); 27 Aug 2018 21:35:48 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 31322 invoked by uid 89); 27 Aug 2018 21:35:47 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.2 spammy=braces X-HELO: sesbmg22.ericsson.net Received: from sesbmg22.ericsson.net (HELO sesbmg22.ericsson.net) (193.180.251.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 27 Aug 2018 21:35:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/simple; q=dns/txt; i=@ericsson.com; t=1535405743; h=From:Sender:Reply-To:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=g2yHLPyGdClGNJQYKA/jTkL2ooQtpfFQnuZSKue88Hs=; b=aE/GDq2RF/00yLlW/H6NkD+eDADkzTq5SghBunx9NCCrzRFA8Wcf8AYWI2M2FZwF J4EMcEBM/fbN8hDUPNXsAGeQKO/uZU/0ppM4skg9S2h0VuxTy+AlXM/uJ5ypm1Ts S/l6KQm0emt5VBplpbOJOJm9fMRSh/IdQVVAOVsiFI0=; Received: from ESESBMB502.ericsson.se (Unknown_Domain [153.88.183.115]) by sesbmg22.ericsson.net (Symantec Mail Security) with SMTP id CB.4C.21978.FAE648B5; Mon, 27 Aug 2018 23:35:43 +0200 (CEST) Received: from ESESBMB503.ericsson.se (153.88.183.170) by ESESBMB502.ericsson.se (153.88.183.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Mon, 27 Aug 2018 23:35:43 +0200 Received: from NAM04-SN1-obe.outbound.protection.outlook.com (153.88.183.157) by ESESBMB503.ericsson.se (153.88.183.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3 via Frontend Transport; Mon, 27 Aug 2018 23:35:42 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2hgrrbnCScfXrr9i34I4JXtXBLkDgzyfxyT5lz+Jc2E=; b=FTBcu7cRnxq4QslEy4upje3k3GPonuvq2x1MSCiXERy6EynudvvpSy89wfxX/h31v/hGOfEISHU7cpEEtR3XzhiDq+4yqCKVBX1YHXq5DwKZFJU7bksrU+4CRsB2OZVu1cppuIvVCLRzAqoRStBsESoi6wCQtoaf5ViMT0+9ChI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=simon.marchi@ericsson.com; Received: from [142.133.48.188] (192.75.88.130) by BN7PR15MB2386.namprd15.prod.outlook.com (2603:10b6:406:8c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.13; Mon, 27 Aug 2018 21:35:39 +0000 Subject: Re: [PATCH] Remove some uses VEC from parsers To: Tom Tromey , References: <20180827211901.20992-1-tom@tromey.com> From: Simon Marchi Message-ID: <2a9d9432-3bd3-f4c7-0817-dbf6ad7d655d@ericsson.com> Date: Mon, 27 Aug 2018 21:35:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180827211901.20992-1-tom@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Return-Path: simon.marchi@ericsson.com Received-SPF: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) X-IsSubscribed: yes X-SW-Source: 2018-08/txt/msg00676.txt.bz2 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_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