Change typed-vector iterator API

Nathan Sidwell nathan@codesourcery.com
Mon Jul 19 20:43:00 GMT 2004


The typed vector iterator API was using the return value for two things
(a) the looping condition, and (b) the element pointer.  This turned out
to be wrong.
1) vectors of possibly NULL pointers cannot be iterated over (documented
restriction)
2) The loop overhead was poor - mostly vectors don't have null pointers
so we shouldn't check for them.

This patch changes the API to return the element pointer by an additional
pointer parameter.  Because the function is inlining, the addressof gunk
gets flattened, so there is no inefficiency in this interface.

Whilst doing the conversion, I uncovered some possibly buggy code in Mark's
conversion of g++'s METHOD_VEC, due to #1 above. Thus convincing me that
the older API is definitely wrong.

I've installed this patch after bootstrapping on i686-pc-linux-gnu.

nathan

-- 
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: vec.h.patch
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20040719/ac37861b/attachment.ksh>


More information about the Gcc-patches mailing list