From 37ba937e050555c0056f93d8b733f637596821ee Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Fri, 25 Aug 2023 18:57:06 -0700 Subject: [PATCH] Fix code style and simplify conditions prev_sibling_c is never NULL so it should be safe to check first_child instead, which ensures we may the minumum cost when the feature isn't enabled. --- src/pugixml.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 72c8d35..3fd953f 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -271,7 +271,7 @@ PUGI_IMPL_NS_BEGIN #endif } - // concat two strings and store it in the first one + // Append one string to another PUGI_IMPL_FN void strconcat(char_t* dst, const char_t* src) { assert(dst && src); @@ -3495,11 +3495,9 @@ PUGI_IMPL_NS_BEGIN } else { - xml_node_struct* cursor_last_child = cursor->first_child ? cursor->first_child->prev_sibling_c + 0 : 0; - - if(PUGI_IMPL_OPTSET(parse_merge_pcdata) && cursor_last_child && PUGI_IMPL_NODETYPE(cursor_last_child) == node_pcdata) + if (PUGI_IMPL_OPTSET(parse_merge_pcdata) && cursor->first_child && PUGI_IMPL_NODETYPE(cursor->first_child->prev_sibling_c) == node_pcdata) { - strconcat(cursor_last_child->value, parsed_pcdata);//Appending PCDATA with the previous one + strconcat(cursor->first_child->prev_sibling_c->value, parsed_pcdata); // Append PCDATA to the previous one. } else {