[PATCH:MI] Return a subset of a variable object's children

Marc Khouzam marc.khouzam@ericsson.com
Wed Apr 30 16:29:00 GMT 2008


> > > > > 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



More information about the Gdb-patches mailing list