summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-08-27 11:40:59 +0200
committerStephan Bergmann <sbergman@redhat.com>2020-08-28 08:07:09 +0200
commit33ecd0d5c4fff9511a8436513936a3f7044a775a (patch)
treec25809adda140ff89d9f2a2b6dfadba17e188fb0 /sal
parent554834484a3323f73b5aeace246bcd9635368967 (diff)
Change OUStringLiteral from char[] to char16_t[]
This is a prerequisite for making conversion from OUStringLiteral to OUString more efficient at least for C++20 (by replacing its internals with a constexpr- generated sal_uString-compatible layout with a SAL_STRING_STATIC_FLAG refCount, conditionally for C++20 for now). For a configure-wise bare-bones build on Linux, size reported by `du -bs instdir` grew by 118792 bytes from 1155636636 to 1155755428. In most places just a u"..." string literal prefix had to be added. In some places char const a[] = "..."; variables have been changed to char16_t, and a few places required even further changes to code (which prompted the addition of include/o3tl/string_view.hxx helper function o3tl::equalsIgnoreAsciiCase and the additional OUString::createFromAscii overload). For all uses of macros expanding to string literals, the relevant uses have been rewritten as u"" MACRO instead of changing the macro definitions. It should be possible to change at least some of those macro definitions (and drop the u"" from their call sites) in follow-up commits. Change-Id: Iec4ef1a057d412d22443312d40c6a8a290dc6144 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101483 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sal')
-rw-r--r--sal/osl/w32/path_helper.cxx4
-rw-r--r--sal/qa/osl/pipe/osl_Pipe.cxx4
-rw-r--r--sal/qa/osl/security/osl_Security.cxx2
-rw-r--r--sal/qa/rtl/oustringbuffer/test_oustringbuffer_assign.cxx6
-rw-r--r--sal/qa/rtl/strings/test_ostring_concat.cxx2
-rw-r--r--sal/qa/rtl/strings/test_oustring_concat.cxx8
-rw-r--r--sal/qa/rtl/strings/test_oustring_stringliterals.cxx78
7 files changed, 52 insertions, 52 deletions
diff --git a/sal/osl/w32/path_helper.cxx b/sal/osl/w32/path_helper.cxx
index eeb45ce885be..52808b3a9774 100644
--- a/sal/osl/w32/path_helper.cxx
+++ b/sal/osl/w32/path_helper.cxx
@@ -25,8 +25,8 @@
#include <algorithm>
#include <wchar.h>
-const OUStringLiteral BACKSLASH ("\\");
-const OUStringLiteral SLASH ("/");
+const OUStringLiteral BACKSLASH (u"\\");
+const OUStringLiteral SLASH (u"/");
void osl_systemPathEnsureSeparator(/*inout*/ rtl_uString** ppustrPath)
{
diff --git a/sal/qa/osl/pipe/osl_Pipe.cxx b/sal/qa/osl/pipe/osl_Pipe.cxx
index bf55bc1e975b..395350f5f5e9 100644
--- a/sal/qa/osl/pipe/osl_Pipe.cxx
+++ b/sal/qa/osl/pipe/osl_Pipe.cxx
@@ -87,8 +87,8 @@ static void printPipeError( ::osl::Pipe const & aPipe )
// pipe name and transfer contents
-const OUStringLiteral aTestPipeName("testpipe2");
-const OUStringLiteral aTestPipe1("testpipe1");
+const OUStringLiteral aTestPipeName(u"testpipe2");
+const OUStringLiteral aTestPipe1(u"testpipe1");
const OStringLiteral m_pTestString1("Sun Microsystems");
const OStringLiteral m_pTestString2("test pipe PASS/OK");
diff --git a/sal/qa/osl/security/osl_Security.cxx b/sal/qa/osl/security/osl_Security.cxx
index f37187480205..0026975fa760 100644
--- a/sal/qa/osl/security/osl_Security.cxx
+++ b/sal/qa/osl/security/osl_Security.cxx
@@ -448,7 +448,7 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *,
// for "JohnSmith" without domain returns domain itself. Try getting the SID of the
// user using fully qualified name (the case of user of another domain having name
// identical this hostname is not handled).
- sLookupUserName = o3tl::toU(wszDomainName) + OUStringLiteral("\\") + strUserName;
+ sLookupUserName = o3tl::toU(wszDomainName) + OUStringLiteral(u"\\") + strUserName;
wszAccName = o3tl::toW(sLookupUserName.getStr());
continue;
}
diff --git a/sal/qa/rtl/oustringbuffer/test_oustringbuffer_assign.cxx b/sal/qa/rtl/oustringbuffer/test_oustringbuffer_assign.cxx
index 0d9cd2b82083..dc09f2a0da08 100644
--- a/sal/qa/rtl/oustringbuffer/test_oustringbuffer_assign.cxx
+++ b/sal/qa/rtl/oustringbuffer/test_oustringbuffer_assign.cxx
@@ -55,13 +55,13 @@ private:
CPPUNIT_ASSERT_EQUAL(s3, b3.toString());
CPPUNIT_ASSERT_EQUAL(sal_Int32(32), b3.getCapacity());
OUStringBuffer b4;
- b4 = OUStringLiteral("1") + "23456789012345";
+ b4 = OUStringLiteral(u"1") + "23456789012345";
CPPUNIT_ASSERT_EQUAL(s1, b4.toString());
CPPUNIT_ASSERT_EQUAL(sal_Int32(16), b4.getCapacity());
- b4 = OUStringLiteral("a") + "bc";
+ b4 = OUStringLiteral(u"a") + "bc";
CPPUNIT_ASSERT_EQUAL(s2, b4.toString());
CPPUNIT_ASSERT_EQUAL(sal_Int32(16), b4.getCapacity());
- b4 = OUStringLiteral("1") + "234567890123456";
+ b4 = OUStringLiteral(u"1") + "234567890123456";
CPPUNIT_ASSERT_EQUAL(s3, b4.toString());
CPPUNIT_ASSERT_EQUAL(sal_Int32(32), b4.getCapacity());
}
diff --git a/sal/qa/rtl/strings/test_ostring_concat.cxx b/sal/qa/rtl/strings/test_ostring_concat.cxx
index bcb4a3e3bb23..1e7ae6da25e4 100644
--- a/sal/qa/rtl/strings/test_ostring_concat.cxx
+++ b/sal/qa/rtl/strings/test_ostring_concat.cxx
@@ -158,7 +158,7 @@ void test::ostring::StringConcat::checkInvalid()
CPPUNIT_ASSERT( INVALID_CONCAT( OString( "a" ) + OStringBuffer( "b" )));
CPPUNIT_ASSERT( INVALID_CONCAT( OString( "a" ) + OUString( "b" )));
CPPUNIT_ASSERT( INVALID_CONCAT( OString( "a" ) + OUStringBuffer( "b" )));
- CPPUNIT_ASSERT( INVALID_CONCAT( OString( "a" ) + OUStringLiteral( "b" )));
+ CPPUNIT_ASSERT( INVALID_CONCAT( OString( "a" ) + OUStringLiteral( u"b" )));
CPPUNIT_ASSERT( INVALID_CONCAT( OString( "a" ) + rtl::OUStringView( u"b" )));
CPPUNIT_ASSERT( INVALID_CONCAT( OString( "a" ) + 1 ));
rtl_String* rs = nullptr;
diff --git a/sal/qa/rtl/strings/test_oustring_concat.cxx b/sal/qa/rtl/strings/test_oustring_concat.cxx
index 0e10257ea7e5..4ffe20966a09 100644
--- a/sal/qa/rtl/strings/test_oustring_concat.cxx
+++ b/sal/qa/rtl/strings/test_oustring_concat.cxx
@@ -66,8 +66,8 @@ void test::oustring::StringConcat::checkConcat()
CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, const char[ 4 ] > )), typeid( OUString( "foo" ) + "bar" ));
CPPUNIT_ASSERT_EQUAL( OUString( "foobarbaz" ), OUString( OUString( "foo" ) + "bar" + "baz" ));
CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUStringConcat< OUString, const char[ 4 ] >, const char[ 4 ] > )), typeid( OUString( "foo" ) + "bar" + "baz" ));
- CPPUNIT_ASSERT_EQUAL( OUString( "foobar" ), OUString( OUStringLiteral( "foo" ) + "bar" ));
- CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUStringLiteral, const char[ 4 ] > )), typeid( OUStringLiteral( "foo" ) + "bar" ));
+ CPPUNIT_ASSERT_EQUAL( OUString( "foobar" ), OUString( OUStringLiteral( u"foo" ) + "bar" ));
+ CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUStringLiteral, const char[ 4 ] > )), typeid( OUStringLiteral( u"foo" ) + "bar" ));
const char d1[] = "xyz";
CPPUNIT_ASSERT_EQUAL( OUString( "fooxyz" ), OUString( OUString( "foo" ) + d1 ));
CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, const char[ 4 ] > )), typeid( OUString( "foo" ) + d1 ));
@@ -148,10 +148,10 @@ void test::oustring::StringConcat::checkEnsureCapacity()
void test::oustring::StringConcat::checkAppend()
{
OUString str( "foo" );
- str += OUStringLiteral( "bar" ) + "baz";
+ str += OUStringLiteral( u"bar" ) + "baz";
CPPUNIT_ASSERT_EQUAL( OUString( "foobarbaz" ), str );
OUStringBuffer buf( "foo" );
- buf.append( OUStringLiteral( "bar" ) + "baz" );
+ buf.append( OUStringLiteral( u"bar" ) + "baz" );
CPPUNIT_ASSERT_EQUAL( OUString( "foobarbaz" ), buf.makeStringAndClear());
}
diff --git a/sal/qa/rtl/strings/test_oustring_stringliterals.cxx b/sal/qa/rtl/strings/test_oustring_stringliterals.cxx
index 9a014557ff59..ea470136c823 100644
--- a/sal/qa/rtl/strings/test_oustring_stringliterals.cxx
+++ b/sal/qa/rtl/strings/test_oustring_stringliterals.cxx
@@ -43,7 +43,7 @@ private:
void testcall( const char str[] );
// Check that OUStringLiteral ctor is actually constexpr:
- static constexpr rtlunittest::OUStringLiteral dummy{"dummy"};
+ static constexpr rtlunittest::OUStringLiteral dummy{u"dummy"};
CPPUNIT_TEST_SUITE(StringLiterals);
CPPUNIT_TEST(checkCtors);
@@ -209,8 +209,8 @@ namespace {
rtl::OUString conditional(bool flag) {
return flag
- ? rtlunittest::OUStringLiteral("a")
- : rtlunittest::OUStringLiteral("bb");
+ ? rtlunittest::OUStringLiteral(u"a")
+ : rtlunittest::OUStringLiteral(u"bb");
}
}
@@ -220,102 +220,102 @@ void test::oustring::StringLiterals::checkOUStringLiteral()
CPPUNIT_ASSERT(bool(conditional(true) == "a"));
CPPUNIT_ASSERT(bool(conditional(false) == "bb"));
- rtl::OUString s1(rtlunittest::OUStringLiteral("abc"));
+ rtl::OUString s1(rtlunittest::OUStringLiteral(u"abc"));
CPPUNIT_ASSERT_EQUAL(rtl::OUString("abc"), s1);
- s1 = rtlunittest::OUStringLiteral("de");
+ s1 = rtlunittest::OUStringLiteral(u"de");
CPPUNIT_ASSERT_EQUAL(rtl::OUString("de"), s1);
- s1 += rtlunittest::OUStringLiteral("fde");
+ s1 += rtlunittest::OUStringLiteral(u"fde");
CPPUNIT_ASSERT_EQUAL(rtl::OUString("defde"), s1);
CPPUNIT_ASSERT_EQUAL(
sal_Int32(0),
- s1.reverseCompareTo(rtlunittest::OUStringLiteral("defde")));
+ s1.reverseCompareTo(rtlunittest::OUStringLiteral(u"defde")));
CPPUNIT_ASSERT(
- s1.equalsIgnoreAsciiCase(rtlunittest::OUStringLiteral("DEFDE")));
- CPPUNIT_ASSERT(s1.match(rtlunittest::OUStringLiteral("fde"), 2));
+ s1.equalsIgnoreAsciiCase(rtlunittest::OUStringLiteral(u"DEFDE")));
+ CPPUNIT_ASSERT(s1.match(rtlunittest::OUStringLiteral(u"fde"), 2));
CPPUNIT_ASSERT(
- s1.matchIgnoreAsciiCase(rtlunittest::OUStringLiteral("FDE"), 2));
+ s1.matchIgnoreAsciiCase(rtlunittest::OUStringLiteral(u"FDE"), 2));
rtl::OUString s2;
- CPPUNIT_ASSERT(s1.startsWith(rtlunittest::OUStringLiteral("de"), &s2));
+ CPPUNIT_ASSERT(s1.startsWith(rtlunittest::OUStringLiteral(u"de"), &s2));
CPPUNIT_ASSERT_EQUAL(rtl::OUString("fde"), s2);
CPPUNIT_ASSERT(
s1.startsWithIgnoreAsciiCase(
- rtlunittest::OUStringLiteral("DEFD"), &s2));
+ rtlunittest::OUStringLiteral(u"DEFD"), &s2));
CPPUNIT_ASSERT_EQUAL(rtl::OUString("e"), s2);
- CPPUNIT_ASSERT(s1.endsWith(rtlunittest::OUStringLiteral("de"), &s2));
+ CPPUNIT_ASSERT(s1.endsWith(rtlunittest::OUStringLiteral(u"de"), &s2));
CPPUNIT_ASSERT_EQUAL(rtl::OUString("def"), s2);
CPPUNIT_ASSERT(
- s1.endsWithIgnoreAsciiCase(rtlunittest::OUStringLiteral("EFDE"), &s2));
+ s1.endsWithIgnoreAsciiCase(rtlunittest::OUStringLiteral(u"EFDE"), &s2));
CPPUNIT_ASSERT_EQUAL(rtl::OUString("d"), s2);
- CPPUNIT_ASSERT(bool(s1 == rtlunittest::OUStringLiteral("defde")));
- CPPUNIT_ASSERT(bool(rtlunittest::OUStringLiteral("defde") == s1));
- CPPUNIT_ASSERT(s1 != rtlunittest::OUStringLiteral("abc"));
- CPPUNIT_ASSERT(rtlunittest::OUStringLiteral("abc") != s1);
+ CPPUNIT_ASSERT(bool(s1 == rtlunittest::OUStringLiteral(u"defde")));
+ CPPUNIT_ASSERT(bool(rtlunittest::OUStringLiteral(u"defde") == s1));
+ CPPUNIT_ASSERT(s1 != rtlunittest::OUStringLiteral(u"abc"));
+ CPPUNIT_ASSERT(rtlunittest::OUStringLiteral(u"abc") != s1);
CPPUNIT_ASSERT_EQUAL(
- sal_Int32(3), s1.indexOf(rtlunittest::OUStringLiteral("de"), 1));
+ sal_Int32(3), s1.indexOf(rtlunittest::OUStringLiteral(u"de"), 1));
CPPUNIT_ASSERT_EQUAL(
- sal_Int32(3), s1.lastIndexOf(rtlunittest::OUStringLiteral("de")));
+ sal_Int32(3), s1.lastIndexOf(rtlunittest::OUStringLiteral(u"de")));
sal_Int32 i = 0;
CPPUNIT_ASSERT_EQUAL(
rtl::OUString("abcfde"),
s1.replaceFirst(
- rtlunittest::OUStringLiteral("de"), rtl::OUString("abc"), &i));
+ rtlunittest::OUStringLiteral(u"de"), rtl::OUString("abc"), &i));
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), i);
CPPUNIT_ASSERT_EQUAL(
rtl::OUString("abcfde"),
s1.replaceFirst(
- rtl::OUString("de"), rtlunittest::OUStringLiteral("abc"), &i));
+ rtl::OUString("de"), rtlunittest::OUStringLiteral(u"abc"), &i));
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), i);
CPPUNIT_ASSERT_EQUAL(
rtl::OUString("abcfde"),
s1.replaceFirst(
- rtlunittest::OUStringLiteral("de"),
- rtlunittest::OUStringLiteral("abc"), &i));
+ rtlunittest::OUStringLiteral(u"de"),
+ rtlunittest::OUStringLiteral(u"abc"), &i));
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), i);
CPPUNIT_ASSERT_EQUAL(
rtl::OUString("abcfde"),
- s1.replaceFirst(rtlunittest::OUStringLiteral("de"), "abc", &i));
+ s1.replaceFirst(rtlunittest::OUStringLiteral(u"de"), "abc", &i));
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), i);
CPPUNIT_ASSERT_EQUAL(
rtl::OUString("abcfde"),
- s1.replaceFirst("de", rtlunittest::OUStringLiteral("abc"), &i));
+ s1.replaceFirst("de", rtlunittest::OUStringLiteral(u"abc"), &i));
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), i);
CPPUNIT_ASSERT_EQUAL(
rtl::OUString("abcfabc"),
s1.replaceAll(
- rtlunittest::OUStringLiteral("de"), rtl::OUString("abc")));
+ rtlunittest::OUStringLiteral(u"de"), rtl::OUString("abc")));
CPPUNIT_ASSERT_EQUAL(
rtl::OUString("abcfabc"),
s1.replaceAll(
- rtl::OUString("de"), rtlunittest::OUStringLiteral("abc")));
+ rtl::OUString("de"), rtlunittest::OUStringLiteral(u"abc")));
CPPUNIT_ASSERT_EQUAL(
rtl::OUString("abcfabc"),
s1.replaceAll(
- rtlunittest::OUStringLiteral("de"),
- rtlunittest::OUStringLiteral("abc")));
+ rtlunittest::OUStringLiteral(u"de"),
+ rtlunittest::OUStringLiteral(u"abc")));
CPPUNIT_ASSERT_EQUAL(
rtl::OUString("abcfabc"),
- s1.replaceAll(rtlunittest::OUStringLiteral("de"), "abc"));
+ s1.replaceAll(rtlunittest::OUStringLiteral(u"de"), "abc"));
CPPUNIT_ASSERT_EQUAL(
rtl::OUString("abcfabc"),
- s1.replaceAll("de", rtlunittest::OUStringLiteral("abc")));
+ s1.replaceAll("de", rtlunittest::OUStringLiteral(u"abc")));
CPPUNIT_ASSERT_EQUAL(
rtl::OUString("abcdef"),
rtl::OUString(
- rtl::OUString("abc") + rtlunittest::OUStringLiteral("def")));
+ rtl::OUString("abc") + rtlunittest::OUStringLiteral(u"def")));
CPPUNIT_ASSERT_EQUAL(
rtl::OUString("abcdef"),
rtl::OUString(
- rtlunittest::OUStringLiteral("abc") + rtl::OUString("def")));
- rtl::OUStringBuffer b(rtlunittest::OUStringLiteral("abc"));
+ rtlunittest::OUStringLiteral(u"abc") + rtl::OUString("def")));
+ rtl::OUStringBuffer b(rtlunittest::OUStringLiteral(u"abc"));
CPPUNIT_ASSERT_EQUAL(rtl::OUString("abc"), b.toString());
- b.append(rtlunittest::OUStringLiteral("def"));
+ b.append(rtlunittest::OUStringLiteral(u"def"));
CPPUNIT_ASSERT_EQUAL(rtl::OUString("abcdef"), b.toString());
- b.insert(2, rtlunittest::OUStringLiteral("gabab"));
+ b.insert(2, rtlunittest::OUStringLiteral(u"gabab"));
CPPUNIT_ASSERT_EQUAL(rtl::OUString("abgababcdef"), b.toString());
CPPUNIT_ASSERT_EQUAL(
- sal_Int32(3), b.indexOf(rtlunittest::OUStringLiteral("ab"), 1));
+ sal_Int32(3), b.indexOf(rtlunittest::OUStringLiteral(u"ab"), 1));
CPPUNIT_ASSERT_EQUAL(
- sal_Int32(5), b.lastIndexOf(rtlunittest::OUStringLiteral("ab")));
+ sal_Int32(5), b.lastIndexOf(rtlunittest::OUStringLiteral(u"ab")));
}
void test::oustring::StringLiterals::checkOUStringChar()