Type safe vector API
Mark Mitchell
mark@codesourcery.com
Fri Jun 25 11:57:00 GMT 2004
Nathan Sidwell wrote:
> Hi,
> Here's a patch which implements a type safe vector API, and a separate
> patch
> which applies it to the CLASSTYPE_VBASECLASSES.
>
> The basic idea is that you define a vector of pointers with
> DEF_VEC_P(typedef)
> and a vector of objects with
> DEF_VEC_O(typedef)
> these produce a structure declaration and a set of inline functions to
> manipulate the vector.
>
> You define a pointer to vector object with
> VEC(typedef) *v;
> and away you go. You have to deal with pointers to vectors, as
> the implementation uses the trailing array hack. There is an API
> call to allow you to have a structure ending with a vector member
> (something that would be useful for a BINFO or TEMPLATE_ARG_VEC).
>
> I couldn't measure time or size difference with this patch, as I
> didn't have a testcase with significant virtual bases.
>
> ok?
I've been waiting to see if someone else would comment.
To me, this looks fine. I'm a little nervous about the way in which
you're using the API for CLASSTYPE_VBASECLASSES in that it looks like
you're conservatively estimating the size of the vector, so it might not
actually be a win over the TREE_LIST thing we have now. As you say,
however, this is a tiny amount of memory one way or the other.
You need comments on some of the functions; for example, macro_input.
If nobody objects in another 24 hours, please go ahead and check this
in. Hopefully the tree-ssa folks can make use of this for their
purposes as well.
--
Mark Mitchell
CodeSourcery, LLC
(916) 791-8304
mark@codesourcery.com
More information about the Gcc-patches
mailing list