summaryrefslogtreecommitdiff
path: root/sdext/source/pdfimport/wrapper
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-06-29 19:47:52 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-06-30 08:50:42 +0200
commit333e24b347293503f1c3abf8871769191b0c751d (patch)
tree84f24c2062b6faa9d6966d3a889ca79303b47ea0 /sdext/source/pdfimport/wrapper
parent8e7edc8c3620e4f733c1974a288e5a5abd29f87e (diff)
tdf#137544 slightly improve perf of pdf parsing
Change-Id: I05af862137666606e557dc3fabe1c3ea249ee10a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136656 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sdext/source/pdfimport/wrapper')
-rw-r--r--sdext/source/pdfimport/wrapper/wrapper.cxx19
1 files changed, 10 insertions, 9 deletions
diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx b/sdext/source/pdfimport/wrapper/wrapper.cxx
index 1e096ccbc11d..da506d9ceef8 100644
--- a/sdext/source/pdfimport/wrapper/wrapper.cxx
+++ b/sdext/source/pdfimport/wrapper/wrapper.cxx
@@ -156,12 +156,12 @@ public:
m_aFontMap(101)
{}
- void parseLine( const OString& rLine );
+ void parseLine( std::string_view aLine );
};
class LineParser {
Parser & m_parser;
- OString m_aLine;
+ std::string_view m_aLine;
static void parseFontFamilyName( FontAttributes& aResult );
void readInt32( sal_Int32& o_Value );
@@ -174,7 +174,7 @@ class LineParser {
public:
std::size_t m_nCharIndex = 0;
- LineParser(Parser & parser, OString const & line): m_parser(parser), m_aLine(line) {}
+ LineParser(Parser & parser, std::string_view line): m_parser(parser), m_aLine(line) {}
std::string_view readNextToken();
sal_Int32 readInt32();
@@ -384,7 +384,7 @@ void LineParser::readChar()
OString aChars;
if (m_nCharIndex != std::string_view::npos)
- aChars = lcl_unescapeLineFeeds( m_aLine.subView( m_nCharIndex ) );
+ aChars = lcl_unescapeLineFeeds( m_aLine.substr( m_nCharIndex ) );
// chars gobble up rest of line
m_nCharIndex = std::string_view::npos;
@@ -552,7 +552,7 @@ void LineParser::readFont()
nSize = nSize < 0.0 ? -nSize : nSize;
// Read FontName. From the current position to the end (any white spaces will be included).
- aFontName = lcl_unescapeLineFeeds(m_aLine.subView(m_nCharIndex));
+ aFontName = lcl_unescapeLineFeeds(m_aLine.substr(m_nCharIndex));
// name gobbles up rest of line
m_nCharIndex = std::string_view::npos;
@@ -776,7 +776,7 @@ void LineParser::readLink()
m_parser.m_pSink->hyperLink( aBounds,
OStringToOUString( lcl_unescapeLineFeeds(
- m_aLine.subView(m_nCharIndex) ),
+ m_aLine.substr(m_nCharIndex) ),
RTL_TEXTENCODING_UTF8 ) );
// name gobbles up rest of line
m_nCharIndex = std::string_view::npos;
@@ -809,13 +809,13 @@ void LineParser::readSoftMaskedImage()
m_parser.m_pSink->drawAlphaMaskedImage( aImage, aMask );
}
-void Parser::parseLine( const OString& rLine )
+void Parser::parseLine( std::string_view aLine )
{
OSL_PRECOND( m_pSink, "Invalid sink" );
OSL_PRECOND( m_pErr, "Invalid filehandle" );
OSL_PRECOND( m_xContext.is(), "Invalid service factory" );
- LineParser lp(*this, rLine);
+ LineParser lp(*this, aLine);
const std::string_view rCmd = lp.readNextToken();
const hash_entry* pEntry = PdfKeywordHash::in_word_set( rCmd.data(),
rCmd.size() );
@@ -1136,7 +1136,8 @@ bool xpdf_ImportFromFile(const OUString& rURL,
if ( line.isEmpty() )
break;
- aParser.parseLine(line.makeStringAndClear());
+ aParser.parseLine(line);
+ line.setLength(0);
}
}
}