summaryrefslogtreecommitdiff
path: root/sal/qa
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2021-10-21 22:03:20 +0200
committerStephan Bergmann <sbergman@redhat.com>2021-10-22 09:24:54 +0200
commitdf42cb6552b20372f62b5a361709670db80e4ed4 (patch)
treefe17971761e7ecf744ef170430c8452c77fa1053 /sal/qa
parente25b8056b25efea0094ef45c315471a7177e7210 (diff)
Optimize assignment from OUStringLiteral to OUString
...by making the OUString's pData point to the OUStringLiteral, instead of copying the contained characters. This is one of the improvements that had not been done as part of e6dfaf9f44f9939abc338c83b3024108431d0f69 "Turn OUStringLiteral into a consteval'ed, static-refcound rtl_uString": "To keep individual commits reasonably manageable, some consumers of OUStringLiteral in rtl/ustrbuf.hxx and rtl/ustring.hxx are left in a somewhat odd state for now, where they don't take advantage of OUStringLiteral's equivalence to rtl_uString, but just keep extracting its contents and copy it elsewhere. In follow-up commits, those consumers should be changed appropriately, making them treat OUStringLiteral like an rtl_uString or dropping the OUStringLiteral overload in favor of an existing (and cheap to use now) OUString overload, etc." (Simply dropping the OUStringLiteral overload was not possible in this case, though, as that would have lead to ambiguities among the various OUString and std::u16string_view overloads.) The now-deleted OUStringLiteral rvalue reference overload means that some existing assignments from ternary-operator OUStringLiteral<N> to OUString no longer compile and had to be replaced with uses of std::u16string_view. Those had not already been replaced in e6dfaf9f44f9939abc338c83b3024108431d0f69 because they happened to use OUStringLiteral instances of identical length N in both arms of the ternary operator, so did not already start to fail to compile back then. Change-Id: I328e25b8324d045774e811d20a639f40d6a9a960 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124040 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sal/qa')
-rw-r--r--sal/qa/rtl/strings/test_oustring_stringliterals.cxx3
1 files changed, 2 insertions, 1 deletions
diff --git a/sal/qa/rtl/strings/test_oustring_stringliterals.cxx b/sal/qa/rtl/strings/test_oustring_stringliterals.cxx
index 5bac89c5af4f..24867050fb7f 100644
--- a/sal/qa/rtl/strings/test_oustring_stringliterals.cxx
+++ b/sal/qa/rtl/strings/test_oustring_stringliterals.cxx
@@ -188,7 +188,8 @@ void test::oustring::StringLiterals::checkOUStringLiteral()
static constexpr rtlunittest::OUStringLiteral s1lit(u"abc");
rtl::OUString s1(s1lit);
CPPUNIT_ASSERT_EQUAL(rtl::OUString("abc"), s1);
- s1 = rtlunittest::OUStringLiteral(u"de");
+ static constexpr rtlunittest::OUStringLiteral de(u"de");
+ s1 = de;
CPPUNIT_ASSERT_EQUAL(rtl::OUString("de"), s1);
s1 += rtlunittest::OUStringLiteral(u"fde");
CPPUNIT_ASSERT_EQUAL(rtl::OUString("defde"), s1);