From 1227d51ed0e1e98679b3e91dfed4a76a2f2e0842 Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Fri, 5 Dec 2014 13:41:45 +0300 Subject: [PATCH] Reuse const FindAttribute for non-const version thereof --- tinyxml2.cpp | 11 ----------- tinyxml2.h | 4 +++- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/tinyxml2.cpp b/tinyxml2.cpp index 06cd441..fc746de 100755 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -1243,17 +1243,6 @@ XMLElement::~XMLElement() } -XMLAttribute* XMLElement::FindAttribute( const char* name ) -{ - for( XMLAttribute* a = _rootAttribute; a; a = a->_next ) { - if ( XMLUtil::StringEqual( a->Name(), name ) ) { - return a; - } - } - return 0; -} - - const XMLAttribute* XMLElement::FindAttribute( const char* name ) const { for( XMLAttribute* a = _rootAttribute; a; a = a->_next ) { diff --git a/tinyxml2.h b/tinyxml2.h index 10ba955..a5d145b 100755 --- a/tinyxml2.h +++ b/tinyxml2.h @@ -1491,7 +1491,9 @@ private: XMLElement( const XMLElement& ); // not supported void operator=( const XMLElement& ); // not supported - XMLAttribute* FindAttribute( const char* name ); + XMLAttribute* FindAttribute( const char* name ) { + return const_cast(const_cast(this)->FindAttribute( name )); + } XMLAttribute* FindOrCreateAttribute( const char* name ); //void LinkAttribute( XMLAttribute* attrib ); char* ParseAttributes( char* p );