Don't assume order of xml attributes

Daniel Jacobowitz dan@codesourcery.com
Wed Feb 2 16:34:00 GMT 2011


On Wed, Feb 02, 2011 at 04:19:36PM +0000, Pedro Alves wrote:
> Something I noticed by inspection while adding support for
> a new xml file fetched with qXfer:$object.
> 
> XML attributes are not ordered.  We should not
> rely on attribute order for anything.  This patch
> adds a helper function to get at a given attribute by name,
> and updates all places to use it instead of refering to
> attributes by index.

This was not required.  The attributes don't have to be ordered in the
XML file, but they're ordered in the VEC because we create it that way
in gdb_start_element.  You can tell your patch still relies on this
code because the calls to the lookup function mostly don't check for
NULL.

That said, I don't think a linear search for attribute names is going
to be too slow :-)  So this is a nice readability improvement anyway.

-- 
Daniel Jacobowitz
CodeSourcery



More information about the Gdb-patches mailing list