From 2874f6f21dc22efab1a2884fe463c5461955a225 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Fri, 8 Jan 2016 08:37:26 -0800 Subject: Add initial support for parse_embed_pcdata When this flag is true, PCDATA value is saved to the parent element instead of allocating a new node. This prevents some documents from round-tripping since it loses information, but can provide a significant memory reduction and parsing speedup for some documents. --- src/pugixml.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/pugixml.cpp') diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 35c0d8e..de87dcf 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -3360,13 +3360,22 @@ PUGI__NS_BEGIN if (cursor->parent || PUGI__OPTSET(parse_fragment)) { - PUGI__PUSHNODE(node_pcdata); // Append a new node on the tree. - cursor->value = s; // Save the offset. + if (!PUGI__OPTSET(parse_embed_pcdata)) + { + PUGI__PUSHNODE(node_pcdata); // Append a new node on the tree. + + cursor->value = s; // Save the offset. + + PUGI__POPNODE(); // Pop since this is a standalone. + } + else + { + if (cursor->parent && !cursor->value) + cursor->value = s; // Save the offset. + } s = strconv_pcdata(s); - PUGI__POPNODE(); // Pop since this is a standalone. - if (!*s) break; } else -- cgit v1.2.3