From 3faa382d4feb3c272333f20e16106a5bbc472990 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 4 Apr 2018 15:49:01 +0000 Subject: Decrease XML parser buffer size This CL decreases the m_iXMLPlaneSize in the CFX_XMLSyntaxParser from 32*1024 to 1024 bytes. This plane size is the size of the chunks we read the XML file in. The issue with having a large plane size is inside the CFX_SeekableStreamProxy::ReadString we allocate a vector of the min(planeSize, remaining_bytes). This means, we could potentially be allocating 32*1024 bytes to read in a single character. For the test in the attached bug the runtime went from 12s to 25ms. Bug: chromium:813195 Change-Id: Id57e619b7a118d45e3fed491ad81e86a4b1cacb8 Reviewed-on: https://pdfium-review.googlesource.com/29750 Reviewed-by: Henrique Nakashima Commit-Queue: dsinclair --- core/fxcrt/xml/cfx_xmlsyntaxparser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp b/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp index c0cc1a6ac9..1fb51b7d52 100644 --- a/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp +++ b/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp @@ -78,7 +78,7 @@ bool CFX_XMLSyntaxParser::IsXMLNameChar(wchar_t ch, bool bFirstChar) { CFX_XMLSyntaxParser::CFX_XMLSyntaxParser( const RetainPtr& pStream) : m_pStream(pStream), - m_iXMLPlaneSize(32 * 1024), + m_iXMLPlaneSize(1024), m_iCurrentPos(0), m_iCurrentNodeNum(-1), m_iLastNodeNum(-1), -- cgit v1.2.3