summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2021-10-01 09:09:45 +0200
committerStephan Bergmann <sbergman@redhat.com>2021-10-11 14:22:22 +0200
commit4f5b3e4bd53d6d61df1f65f496f7bc8dc525c8a1 (patch)
treee0ac44b8f22f944f3303bac8e494da41d6c7b164 /tools
parent5f84c44e3d5ff19b800b6358e61228546e318d4f (diff)
In O[U]StringBuffer, make string_view params replacements for OUString ones
...for LIBO_INTERNAL_ONLY, instead of having them as additional overloads. That way, loplugin:bufferadd and loplugin:stringviewparam found many further opportunities for simplification (all addressed here). Some notes: * There is no longer an implicit conversion from O[U]String to O[U]StringBuffer (as that goes via user-defined conversions through string_view now), which was most noticeable in copy initializations like OStringBuffer buf = someStr; that had to be changed to direct initialization, OStringBuffer buf(someStr); But then again, it wasn't too many places that were affected and I think we can live with that. * I made the O[U]StringBuffer ctors taking string_view non-explicit, mainly to get them in line with their counterparts taking O[U]String. * I added an OUStringBuffer::lastIndexOf string_view overload that was missing (relative to OUStringBuffer::indexOf). * loplugin:stringconstant needed some addition to keep the compilerplugins/clang/test/stringconstant.cxx checks related to OStringBuffer::append and OStringBuffer::insert working. * loplugin:stringviewparam no longer needs the special O[U]StringBuffer-related code that had been introduced in 1250aecd71fabde4dba990bfceb61bbe8e06b8ea "loplugin:stringviewparam extend to new.." Change-Id: Ib1bb8c4632d99b744e742605a9fef6eae959fd72 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122904 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/source/fsys/urlobj.cxx42
1 files changed, 18 insertions, 24 deletions
diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index c17ce9219a84..93e12e965261 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -2823,7 +2823,7 @@ bool INetURLObject::parseHostOrNetBiosName(
return true;
}
-bool INetURLObject::setHost(OUString const & rTheHost,
+bool INetURLObject::setHost(std::u16string_view rTheHost,
rtl_TextEncoding eCharset)
{
if (!getSchemeInfo().m_bHost)
@@ -3691,7 +3691,7 @@ bool INetURLObject::operator ==(INetURLObject const & rObject) const
bool INetURLObject::ConcatData(INetProtocol eTheScheme,
std::u16string_view rTheUser,
std::u16string_view rThePassword,
- OUString const & rTheHost,
+ std::u16string_view rTheHost,
sal_uInt32 nThePort,
OUString const & rThePath)
{
@@ -3799,7 +3799,7 @@ bool INetURLObject::ConcatData(INetProtocol eTheScheme,
}
}
}
- else if (!rTheHost.isEmpty() || nThePort != 0)
+ else if (!rTheHost.empty() || nThePort != 0)
{
setInvalid();
return false;
@@ -4024,12 +4024,11 @@ bool INetURLObject::setName(std::u16string_view rTheName, EncodeMechanism eMecha
while (p != pSegEnd && *p != ';')
++p;
- OUStringBuffer aNewPath(256);
- aNewPath.append(pPathBegin, pSegBegin - pPathBegin);
- aNewPath.append(encodeText(rTheName, PART_PCHAR, eMechanism, eCharset, true));
- aNewPath.append(p, pPathEnd - p);
-
- return setPath(aNewPath.makeStringAndClear(), EncodeMechanism::NotCanonical,
+ return setPath(
+ std::u16string_view(pPathBegin, pSegBegin - pPathBegin)
+ + encodeText(rTheName, PART_PCHAR, eMechanism, eCharset, true)
+ + std::u16string_view(p, pPathEnd - p),
+ EncodeMechanism::NotCanonical,
RTL_TEXTENCODING_UTF8);
}
@@ -4102,13 +4101,11 @@ bool INetURLObject::setBase(std::u16string_view rTheBase, sal_Int32 nIndex,
if (!pExtension)
pExtension = p;
- OUStringBuffer aNewPath;
- aNewPath.append(pPathBegin, pSegBegin - pPathBegin);
- aNewPath.append(encodeText(rTheBase, PART_PCHAR,
- eMechanism, eCharset, true));
- aNewPath.append(pExtension, pPathEnd - pExtension);
-
- return setPath(aNewPath.makeStringAndClear(), EncodeMechanism::NotCanonical,
+ return setPath(
+ std::u16string_view(pPathBegin, pSegBegin - pPathBegin)
+ + encodeText(rTheBase, PART_PCHAR, eMechanism, eCharset, true)
+ + std::u16string_view(pExtension, pPathEnd - pExtension),
+ EncodeMechanism::NotCanonical,
RTL_TEXTENCODING_UTF8);
}
@@ -4164,14 +4161,11 @@ bool INetURLObject::setExtension(std::u16string_view rTheExtension,
if (!pExtension)
pExtension = p;
- OUStringBuffer aNewPath(128);
- aNewPath.append(pPathBegin, pExtension - pPathBegin);
- aNewPath.append('.');
- aNewPath.append(encodeText(rTheExtension, PART_PCHAR,
- EncodeMechanism::WasEncoded, eCharset, true));
- aNewPath.append(p, pPathEnd - p);
-
- return setPath(aNewPath.makeStringAndClear(), EncodeMechanism::NotCanonical,
+ return setPath(
+ OUString::Concat(std::u16string_view(pPathBegin, pExtension - pPathBegin)) + "."
+ + encodeText(rTheExtension, PART_PCHAR, EncodeMechanism::WasEncoded, eCharset, true)
+ + std::u16string_view(p, pPathEnd - p),
+ EncodeMechanism::NotCanonical,
RTL_TEXTENCODING_UTF8);
}