summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-11-12 08:13:40 +0100
committerStephan Bergmann <sbergman@redhat.com>2020-11-12 16:53:30 +0100
commitf34ac579fac16fff37bf00fe85d43ad6b938eca7 (patch)
tree0747c4d86bbf40a5093fb7a3215dd52a8e8586b2 /sw
parentc45753847dfc2b4645dc2f7500a18ec2c5d438df (diff)
New loplugin:stringviewparam
...to "Find functions that take rtl::O[U]String parameters that can be generalized to take std::[u16]string_view instead." (Which in turn can avoid costly O[U]String constructions, see e.g. loplugin:stringview and subView.) Some of those functions' call sites, passing plain char string literals, needed to be adapted when converting them. Change-Id: I644ab546d7a0ce9e470ab9b3196e3e60d1e812bc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105622 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/access/acccell.cxx13
-rw-r--r--sw/source/core/doc/doclay.cxx3
-rw-r--r--sw/source/core/edit/edfcol.cxx8
-rw-r--r--sw/source/core/text/porlay.cxx8
-rw-r--r--sw/source/filter/ascii/wrtasc.cxx3
-rw-r--r--sw/source/filter/xml/wrtxml.cxx3
6 files changed, 25 insertions, 13 deletions
diff --git a/sw/source/core/access/acccell.cxx b/sw/source/core/access/acccell.cxx
index ee533636e29d..a1b52d41c98f 100644
--- a/sw/source/core/access/acccell.cxx
+++ b/sw/source/core/access/acccell.cxx
@@ -39,6 +39,7 @@
#include "acccell.hxx"
#include <cfloat>
+#include <string_view>
#include <editeng/brushitem.hxx>
#include <swatrset.hxx>
@@ -364,7 +365,7 @@ uno::Any SwAccessibleCell::getMinimumValue( )
return uno::Any(-DBL_MAX);
}
-static OUString ReplaceOneChar(const OUString& oldOUString, const OUString& replacedChar, const OUString& replaceStr)
+static OUString ReplaceOneChar(const OUString& oldOUString, std::u16string_view replacedChar, const OUString& replaceStr)
{
int iReplace = oldOUString.lastIndexOf(replacedChar);
OUString aRet = oldOUString;
@@ -378,11 +379,11 @@ static OUString ReplaceOneChar(const OUString& oldOUString, const OUString& repl
static OUString ReplaceFourChar(const OUString& oldOUString)
{
- OUString aRet = ReplaceOneChar(oldOUString,"\\","\\\\");
- aRet = ReplaceOneChar(aRet,";","\\;");
- aRet = ReplaceOneChar(aRet,"=","\\=");
- aRet = ReplaceOneChar(aRet,",","\\,");
- aRet = ReplaceOneChar(aRet,":","\\:");
+ OUString aRet = ReplaceOneChar(oldOUString,u"\\","\\\\");
+ aRet = ReplaceOneChar(aRet,u";","\\;");
+ aRet = ReplaceOneChar(aRet,u"=","\\=");
+ aRet = ReplaceOneChar(aRet,u",","\\,");
+ aRet = ReplaceOneChar(aRet,u":","\\:");
return aRet;
}
diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index 5e03d523dd70..e308e467571b 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -85,6 +85,7 @@
#include <sortedobjs.hxx>
+#include <string_view>
#include <vector>
using namespace ::com::sun::star;
@@ -1273,7 +1274,7 @@ SwFlyFrameFormat* SwDoc::InsertDrawLabel(
return pNewFormat;
}
-static void lcl_collectUsedNums(std::vector<unsigned int>& rSetFlags, sal_Int32 nNmLen, const OUString& rName, const OUString& rCmpName)
+static void lcl_collectUsedNums(std::vector<unsigned int>& rSetFlags, sal_Int32 nNmLen, const OUString& rName, std::u16string_view rCmpName)
{
if (rName.startsWith(rCmpName))
{
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index 0812f3bebc8b..49d7e26e9acc 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -17,6 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <string_view>
+
#include <editsh.hxx>
#include <com/sun/star/container/XEnumerationAccess.hpp>
@@ -277,7 +281,7 @@ std::map<OUString, OUString> lcl_getRDFStatements(const uno::Reference<frame::XM
/// Returns RDF (key, value) pair associated with the field, if any.
std::pair<OUString, OUString> lcl_getFieldRDFByPrefix(const uno::Reference<frame::XModel>& xModel,
const uno::Reference<css::text::XTextField>& xField,
- const OUString& sPrefix)
+ std::u16string_view sPrefix)
{
for (const auto& pair : lcl_getRDFStatements(xModel, xField))
{
@@ -705,7 +709,7 @@ static void insertFieldToDocument(uno::Reference<lang::XMultiServiceFactory> con
rxText->insertTextContent(rxParagraphCursor, xTextContent, false);
}
-static void removeAllClassificationFields(OUString const & rPolicy, uno::Reference<text::XText> const & rxText)
+static void removeAllClassificationFields(std::u16string_view rPolicy, uno::Reference<text::XText> const & rxText)
{
uno::Reference<container::XEnumerationAccess> xParagraphEnumerationAccess(rxText, uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xParagraphs = xParagraphEnumerationAccess->createEnumeration();
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index 7a72d65b12f4..06a4e5f4b7c7 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -17,6 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <string_view>
+
#include "porlay.hxx"
#include "itrform2.hxx"
#include "porglue.hxx"
@@ -157,7 +161,7 @@ static bool lcl_ConnectToPrev( sal_Unicode cCh, sal_Unicode cPrevCh )
return bRet;
}
-static bool lcl_HasStrongLTR ( const OUString& rText, sal_Int32 nStart, sal_Int32 nEnd )
+static bool lcl_HasStrongLTR ( std::u16string_view rText, sal_Int32 nStart, sal_Int32 nEnd )
{
for( sal_Int32 nCharIdx = nStart; nCharIdx < nEnd; ++nCharIdx )
{
@@ -313,7 +317,7 @@ void SwLineLayout::CreateSpaceAdd( const tools::Long nInit )
}
// Returns true if there are only blanks in [nStt, nEnd[
-static bool lcl_HasOnlyBlanks(const OUString& rText, TextFrameIndex nStt, TextFrameIndex nEnd)
+static bool lcl_HasOnlyBlanks(std::u16string_view rText, TextFrameIndex nStt, TextFrameIndex nEnd)
{
bool bBlankOnly = true;
while ( nStt < nEnd )
diff --git a/sw/source/filter/ascii/wrtasc.cxx b/sw/source/filter/ascii/wrtasc.cxx
index 5ea4560e9907..3c618ecb5b52 100644
--- a/sw/source/filter/ascii/wrtasc.cxx
+++ b/sw/source/filter/ascii/wrtasc.cxx
@@ -203,7 +203,8 @@ ErrCode SwASCWriter::WriteStream()
return ERRCODE_NONE;
}
-void GetASCWriter( const OUString& rFltNm, const OUString& /*rBaseURL*/, WriterRef& xRet )
+void GetASCWriter(
+ const OUString& rFltNm, [[maybe_unused]] const OUString& /*rBaseURL*/, WriterRef& xRet )
{
xRet = new SwASCWriter( rFltNm );
}
diff --git a/sw/source/filter/xml/wrtxml.cxx b/sw/source/filter/xml/wrtxml.cxx
index 3c1a468474ff..d8764612cc72 100644
--- a/sw/source/filter/xml/wrtxml.cxx
+++ b/sw/source/filter/xml/wrtxml.cxx
@@ -559,7 +559,8 @@ bool SwXMLWriter::WriteThroughComponent(
return xFilter->filter( rMediaDesc );
}
-void GetXMLWriter( const OUString& /*rName*/, const OUString& rBaseURL, WriterRef& xRet )
+void GetXMLWriter(
+ [[maybe_unused]] const OUString& /*rName*/, const OUString& rBaseURL, WriterRef& xRet )
{
xRet = new SwXMLWriter( rBaseURL );
}