From: Václav Slavík Date: Sun, 3 May 2009 07:10:23 +0000 (+0000) Subject: optimized handling for the common case of simple reference with no overw... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/44108a078fae492eadbef70c1256c3625d95e676 optimized handling for the common case of simple reference with no overwrites git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60494 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/xrc/xmlres.cpp b/src/xrc/xmlres.cpp index 090d7da5f2..e9942ba285 100644 --- a/src/xrc/xmlres.cpp +++ b/src/xrc/xmlres.cpp @@ -844,14 +844,31 @@ wxObject *wxXmlResource::CreateResFromNode(wxXmlNode *node, wxObject *parent, return NULL; } - wxXmlNode copy(*refNode); - MergeNodesOver(copy, *node, GetFileNameFromNode(node, Data())); + if ( !node->GetChildren() ) + { + // In the typical, simple case, is used to link + // to another node and doesn't have any content of its own that + // would overwrite linked object's properties. In this case, + // we can simply create the resource from linked node. + + return CreateResFromNode(refNode, parent, instance); + } + else + { + // In the more complicated (but rare) case, has + // subnodes that partially overwrite content of the referenced + // object. In this case, we need to merge both XML trees and + // load the resource from result of the merge. + + wxXmlNode copy(*refNode); + MergeNodesOver(copy, *node, GetFileNameFromNode(node, Data())); - // remember referenced object's file, see GetFileNameFromNode() - copy.AddAttribute(ATTR_INPUT_FILENAME, - GetFileNameFromNode(refNode, Data())); + // remember referenced object's file, see GetFileNameFromNode() + copy.AddAttribute(ATTR_INPUT_FILENAME, + GetFileNameFromNode(refNode, Data())); - return CreateResFromNode(©, parent, instance); + return CreateResFromNode(©, parent, instance); + } } if (handlerToUse)