From 8752982b784ded7633e892fd5243fbc760ea0b22 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Wed, 18 Dec 2024 11:35:53 +0900 Subject: [PATCH] Base: Improved FindElement performance by reducing call of transcode --- src/Base/Parameter.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Base/Parameter.cpp b/src/Base/Parameter.cpp index b2308a7804..1b0b97722a 100644 --- a/src/Base/Parameter.cpp +++ b/src/Base/Parameter.cpp @@ -1396,15 +1396,19 @@ ParameterGrp::FindElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* Start, Type); return nullptr; } + const XStr xType(Type); + const XStr xName(Name); for (DOMNode* clChild = Start->getFirstChild(); clChild != nullptr; clChild = clChild->getNextSibling()) { if (clChild->getNodeType() == DOMNode::ELEMENT_NODE) { // the right node Type - if (!strcmp(Type, StrX(clChild->getNodeName()).c_str())) { + if (!XMLString::compareString(xType.unicodeForm(), clChild->getNodeName())) { if (clChild->getAttributes()->getLength() > 0) { if (Name) { DOMNode* attr = FindAttribute(clChild, "Name"); - if (attr && !strcmp(Name, StrX(attr->getNodeValue()).c_str())) { + if (attr + && !XMLString::compareString(xName.unicodeForm(), + attr->getNodeValue())) { return dynamic_cast(clChild); } } @@ -1426,10 +1430,11 @@ ParameterGrp::FindNextElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* Prev, cons return nullptr; } + const XStr xType(Type); while ((clChild = clChild->getNextSibling()) != nullptr) { if (clChild->getNodeType() == DOMNode::ELEMENT_NODE) { // the right node Type - if (!strcmp(Type, StrX(clChild->getNodeName()).c_str())) { + if (!XMLString::compareString(xType.unicodeForm(), clChild->getNodeName())) { return dynamic_cast(clChild); } }