From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24684 invoked by alias); 2 Feb 2011 16:34:01 -0000 Received: (qmail 24672 invoked by uid 22791); 2 Feb 2011 16:34:00 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 02 Feb 2011 16:33:56 +0000 Received: (qmail 17779 invoked from network); 2 Feb 2011 16:33:54 -0000 Received: from unknown (HELO caradoc.them.org) (dan@127.0.0.2) by mail.codesourcery.com with ESMTPA; 2 Feb 2011 16:33:54 -0000 Date: Wed, 02 Feb 2011 16:34:00 -0000 From: Daniel Jacobowitz To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: Don't assume order of xml attributes Message-ID: <20110202163343.GA9355@caradoc.them.org> Mail-Followup-To: Pedro Alves , gdb-patches@sourceware.org References: <201102021619.36863.pedro@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201102021619.36863.pedro@codesourcery.com> User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-02/txt/msg00018.txt.bz2 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