From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26171 invoked by alias); 1 May 2008 15:56:13 -0000 Received: (qmail 26163 invoked by uid 22791); 1 May 2008 15:56:12 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 01 May 2008 15:55:55 +0000 Received: (qmail 20338 invoked from network); 1 May 2008 15:55:53 -0000 Received: from unknown (HELO localhost) (vladimir@127.0.0.2) by mail.codesourcery.com with ESMTPA; 1 May 2008 15:55:53 -0000 From: Vladimir Prus To: "Marc Khouzam" Subject: Re: [PATCH:MI] Return a subset of a variable object's children Date: Thu, 01 May 2008 15:56:00 -0000 User-Agent: KMail/1.9.6 (enterprise 0.20070907.709405) Cc: "Nick Roberts" , gdb-patches@sources.redhat.com References: <6D19CA8D71C89C43A057926FE0D4ADAA042910B7@ecamlmw720.eamcs.ericsson.se> In-Reply-To: <6D19CA8D71C89C43A057926FE0D4ADAA042910B7@ecamlmw720.eamcs.ericsson.se> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200805011955.54191.vladimir@codesourcery.com> 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 X-SW-Source: 2008-05/txt/msg00011.txt.bz2 On Wednesday 30 April 2008 18:21:03 Marc Khouzam wrote: > > > > > > but only actually create the children that have been requested by the > > > > > > user. I'm not sure how much efficiency there is by allocating the > > > > > > memory before hand? Also, is there no way to grow the vector by more > > > > > > than a single point at a time? > > > > > > > > > > Like resize with STL vectors? I'm not aware of one. > > > > > > > > VEC_safe_grow > > > > > > OK, I didn't know about that. Why not use it instead of VEC_safe_push in the > > > construct above? > > > > Well, it happens not to initialize the data, so some changes in further logic will > > be required. Until now, it was not a performance issue. > > My concern about > > while (VEC_length (varobj_p, var->children) < var->num_children) > VEC_safe_push (varobj_p, var->children, NULL); > > is that the vector may be reallocated multiple times. As soon as we're into big-O here, we still get amortized linear time. > How about something like this (assuming quick_push does what I think it does) > > var->children = VEC_alloc(varobj_p, var->num_children); > for (i=0; inum_children; i++) > VEC_quick_push (varobj_p, var->children, NULL); > > Same loop, but it avoids having to reallocate the vector. Yes, it's a bit more efficient. - Volodya