From 28580110807a38e3ba6f8385f22871b8dfe0a910 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 31 Jul 2018 13:13:36 +0200 Subject: add operator+=(OUStringBuffer) method to OUString to reduce needless object creation and copying some more And fix what looks like a bug in CSS hex color parsing at line 609 in sw/../parcss1.cxx that has been there since commit 7b0b5cdfeed656b279bc32cd929630d5fc25878b "initial import" Change-Id: Ibad42b23721a56493bd1edcd7165e6104494a5c3 Reviewed-on: https://gerrit.libreoffice.org/58357 Tested-by: Jenkins Reviewed-by: Noel Grandin --- svtools/source/svhtml/parhtml.cxx | 51 +++++++++++++++++++++++++++++---------- svtools/source/svrtf/parrtf.cxx | 8 +++--- 2 files changed, 42 insertions(+), 17 deletions(-) (limited to 'svtools') diff --git a/svtools/source/svhtml/parhtml.cxx b/svtools/source/svhtml/parhtml.cxx index d887f4084ab8..a25f6f547517 100644 --- a/svtools/source/svhtml/parhtml.cxx +++ b/svtools/source/svhtml/parhtml.cxx @@ -537,7 +537,8 @@ HtmlTokenId HTMLParser::ScanText( const sal_Unicode cBreak ) else { // If not scanning a tag return token - aToken += sTmpBuffer.makeStringAndClear(); + aToken += sTmpBuffer; + sTmpBuffer.setLength(0); if( !aToken.isEmpty() ) { @@ -588,7 +589,10 @@ HtmlTokenId HTMLParser::ScanText( const sal_Unicode cBreak ) // options. sTmpBuffer.append( '\\' ); if( MAX_LEN == sTmpBuffer.getLength() ) - aToken += sTmpBuffer.makeStringAndClear(); + { + aToken += sTmpBuffer; + sTmpBuffer.setLength(0); + } } if( IsParserWorking() ) { @@ -626,7 +630,10 @@ HtmlTokenId HTMLParser::ScanText( const sal_Unicode cBreak ) // mark within tags sTmpBuffer.append( '\\' ); if( MAX_LEN == sTmpBuffer.getLength() ) - aToken += sTmpBuffer.makeStringAndClear(); + { + aToken += sTmpBuffer; + sTmpBuffer.setLength(0); + } } sTmpBuffer.append( '\\' ); break; @@ -721,7 +728,8 @@ HtmlTokenId HTMLParser::ScanText( const sal_Unicode cBreak ) if( !aToken.isEmpty() || sTmpBuffer.getLength() > 1 ) { // Have seen s.th. aside from blanks? - aToken += sTmpBuffer.makeStringAndClear(); + aToken += sTmpBuffer; + sTmpBuffer.setLength(0); return HtmlTokenId::TEXTTOKEN; } else @@ -747,14 +755,15 @@ HtmlTokenId HTMLParser::ScanText( const sal_Unicode cBreak ) sTmpBuffer.appendUtf32( nNextCh ); if( MAX_LEN == sTmpBuffer.getLength() ) { - aToken += sTmpBuffer.makeStringAndClear(); + aToken += sTmpBuffer; + sTmpBuffer.setLength(0); } if( ( sal_Unicode(EOF) == (nNextCh = GetNextChar()) && rInput.eof() ) || !IsParserWorking() ) { if( !sTmpBuffer.isEmpty() ) - aToken += sTmpBuffer.makeStringAndClear(); + aToken += sTmpBuffer; return HtmlTokenId::TEXTTOKEN; } } while( rtl::isAsciiAlpha( nNextCh ) || rtl::isAsciiDigit( nNextCh ) ); @@ -763,14 +772,17 @@ HtmlTokenId HTMLParser::ScanText( const sal_Unicode cBreak ) } if( MAX_LEN == sTmpBuffer.getLength() ) - aToken += sTmpBuffer.makeStringAndClear(); + { + aToken += sTmpBuffer; + sTmpBuffer.setLength(0); + } if( bContinue && bNextCh ) nNextCh = GetNextChar(); } if( !sTmpBuffer.isEmpty() ) - aToken += sTmpBuffer.makeStringAndClear(); + aToken += sTmpBuffer; return HtmlTokenId::TEXTTOKEN; } @@ -805,7 +817,8 @@ HtmlTokenId HTMLParser::GetNextRawToken() // Maybe we've reached the end. // Save what we have read previously... - aToken += sTmpBuffer.makeStringAndClear(); + aToken += sTmpBuffer; + sTmpBuffer.setLength(0); // and remember position in stream. sal_uInt64 nStreamPos = rInput.Tell(); @@ -926,7 +939,10 @@ HtmlTokenId HTMLParser::GetNextRawToken() bTwoMinus = true; if( MAX_LEN == sTmpBuffer.getLength() ) - aToken += sTmpBuffer.makeStringAndClear(); + { + aToken += sTmpBuffer; + sTmpBuffer.setLength(0); + } sTmpBuffer.appendUtf32( nNextCh ); nNextCh = GetNextChar(); } @@ -978,7 +994,10 @@ HtmlTokenId HTMLParser::GetNextRawToken() if( (!bContinue && !sTmpBuffer.isEmpty()) || MAX_LEN == sTmpBuffer.getLength() ) - aToken += sTmpBuffer.makeStringAndClear(); + { + aToken += sTmpBuffer; + sTmpBuffer.setLength(0); + } if( bContinue && bNextCh ) nNextCh = GetNextChar(); @@ -1055,13 +1074,19 @@ HtmlTokenId HTMLParser::GetNextToken_() do { sTmpBuffer.appendUtf32( nNextCh ); if( MAX_LEN == sTmpBuffer.getLength() ) - aToken += sTmpBuffer.makeStringAndClear(); + { + aToken += sTmpBuffer; + sTmpBuffer.setLength(0); + } nNextCh = GetNextChar(); } while( '>' != nNextCh && '/' != nNextCh && !rtl::isAsciiWhiteSpace( nNextCh ) && IsParserWorking() && !rInput.eof() ); if( !sTmpBuffer.isEmpty() ) - aToken += sTmpBuffer.makeStringAndClear(); + { + aToken += sTmpBuffer; + sTmpBuffer.setLength(0); + } // Skip blanks while( rtl::isAsciiWhiteSpace( nNextCh ) && IsParserWorking() ) diff --git a/svtools/source/svrtf/parrtf.cxx b/svtools/source/svrtf/parrtf.cxx index 91a53b4381c6..bff4bcacc54e 100644 --- a/svtools/source/svrtf/parrtf.cxx +++ b/svtools/source/svrtf/parrtf.cxx @@ -106,14 +106,14 @@ int SvRTFParser::GetNextToken_() aStrBuffer[nStrLen++] = nNextCh; if( MAX_TOKEN_LEN == nStrLen ) { - aToken += aStrBuffer.toString(); + aToken += aStrBuffer; nStrLen = 0; } nNextCh = GetNextChar(); } while( RTF_ISALPHA( nNextCh ) ); if( nStrLen ) { - aToken += aStrBuffer.makeStringAndClear(); + aToken += aStrBuffer; } } @@ -505,7 +505,7 @@ void SvRTFParser::ScanText() if (sal_Unicode(EOF) == (nNextCh = GetNextChar())) { if (!aStrBuffer.isEmpty()) - aToken += aStrBuffer.toString(); + aToken += aStrBuffer; return; } } while @@ -522,7 +522,7 @@ void SvRTFParser::ScanText() } if (!aStrBuffer.isEmpty()) - aToken += aStrBuffer.makeStringAndClear(); + aToken += aStrBuffer; } -- cgit