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>
- Cc: "Nick Roberts" <nickrob at snap dot net dot nz>, <gdb-patches at sources dot redhat dot com>
- Date: Thu, 1 May 2008 13:25:04 -0400
- Subject: RE: [PATCH:MI] Return a subset of a variable object's children
- References: <6D19CA8D71C89C43A057926FE0D4ADAA042910B7@ecamlmw720.eamcs.ericsson.se> <200805011955.54191.vladimir@codesourcery.com>
> > 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.
>
> Yes, it's a bit more efficient.
In fact, I actually just read the vec.h header comment and that is pretty
much what is recommended. In fact, the size value passed to VEC_alloc
should probably be negative here, to have even more efficiency, since
we know the vector won't grow.
But that is no longer the case with Nick's patch, as the vector will keep
on growing.