From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 129766 invoked by alias); 13 Oct 2016 15:26:22 -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 129445 invoked by uid 89); 13 Oct 2016 15:26:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: paperclip.tbsaunde.org Received: from tbsaunde.org (HELO paperclip.tbsaunde.org) (66.228.47.254) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Oct 2016 15:26:19 +0000 Received: from ball (unknown [IPv6:2607:f0c8:8000:80e0:56ee:75ff:fe52:afb9]) by paperclip.tbsaunde.org (Postfix) with ESMTPSA id C938CC06B; Thu, 13 Oct 2016 15:26:17 +0000 (UTC) Date: Thu, 13 Oct 2016 15:26:00 -0000 From: Trevor Saunders To: Tom Tromey Cc: Pedro Alves , gdb-patches@sourceware.org Subject: Re: [RFA 14/22] Replace two xmallocs with vector Message-ID: <20161013153524.cw6chcjuld2ago47@ball> References: <1474949330-4307-1-git-send-email-tom@tromey.com> <1474949330-4307-15-git-send-email-tom@tromey.com> <2bb436df-b6ee-cc2f-c4c1-1a79d6fcdce1@redhat.com> <87oa2oxpy6.fsf@tromey.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87oa2oxpy6.fsf@tromey.com> User-Agent: NeoMutt/20160916 (1.7.0) X-SW-Source: 2016-10/txt/msg00379.txt.bz2 On Thu, Oct 13, 2016 at 08:51:13AM -0600, Tom Tromey wrote: > >>>>> "Pedro" == Pedro Alves writes: > > Pedro> As general guideline, for these cases where we only need to > Pedro> construct a buffer once (never resize/reallocate) and we don't > Pedro> care about the initial contents of the buffer, I think > Pedro> unique_ptr buf (new char[size]); > Pedro> ends up being more efficient, because std::vector > Pedro> default/zero initializes its elements, which is unnecessary since > Pedro> we're about to write into the buffer anyway. > > I made this change in my patches. > > While doing so I realized one reason to prefer vector: with vector you > can build gdb with the libstdc++ debug mode, and get range checking. On the other hand if there isn't already a debug unique_ptr with the same checking it seems like we should add that. It shouldn't be terribly hard. Trev > > Tom