This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RE: [PATCH:MI] Return a subset of a variable object's children
- From: "Marc Khouzam" <marc dot khouzam at ericsson dot com>
- To: "Vladimir Prus" <vladimir at codesourcery dot com>, "Nick Roberts" <nickrob at snap dot net dot nz>
- Cc: <gdb-patches at sources dot redhat dot com>
- Date: Wed, 30 Apr 2008 10:21:03 -0400
- Subject: RE: [PATCH:MI] Return a subset of a variable object's children
> > > > > 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.
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; i<var->num_children; i++)
VEC_quick_push (varobj_p, var->children, NULL);
Same loop, but it avoids having to reallocate the vector.
Just a thought, not related to Nick's patch.
Marc