simplify
This commit is contained in:
@@ -175,20 +175,16 @@ bool IniFile::DeleteKey(const RString &keyname)
|
|||||||
bool IniFile::RenameKey(const RString &from, const RString &to)
|
bool IniFile::RenameKey(const RString &from, const RString &to)
|
||||||
{
|
{
|
||||||
/* If to already exists, do nothing. */
|
/* If to already exists, do nothing. */
|
||||||
XNode* pTo = GetChild( to );
|
if( GetChild(to) != NULL )
|
||||||
if( pTo )
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
multimap<RString, XNode*>::iterator it = m_childs.find( from );
|
XNode* pNode = GetChild( from );
|
||||||
if( it == m_childs.end() )
|
if( pNode == NULL )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
XNode* pNode = it->second;
|
RemoveChild( pNode, false );
|
||||||
|
pNode->SetName( to );
|
||||||
m_childs.erase( it );
|
AppendChild( pNode );
|
||||||
|
|
||||||
pNode->m_sName = to;
|
|
||||||
m_childs.insert( make_pair(pNode->m_sName, pNode) );
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user