diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2021-09-30 13:54:26 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2021-10-03 19:50:44 +0200 |
commit | ad1557f5d775739230e0e2252c293948977b42a0 (patch) | |
tree | 610e2e849d87583888c0c658088044d6dc3966a5 /desktop | |
parent | 7e7dd7f152bc7457437f541e7ff88d69e9f8e765 (diff) |
A more lightweight O[U]StringConcatenation
...compared to a full-blown O[U]String, for temporary objects holding an
O[U]StringConcat result that can then be used as a std::[u16]string_view.
It's instructive to see how some invocations of operator ==, operator !=, and
O[U]StringBuffer::insert with an O[U]StringConcat argument required implicit
materialization of an O[U]String temporary, and how that expensive operation has
now been made explicit with the explicit O[U]StringConcatenation ctor.
(The additional operator == and operator != overloads are necessary because the
overloads taking two std::[u16]string_view parameters wouldn't even be found
here with ADL. And the OUString-related ones would cause ambiguities in at
least sal/qa/rtl/strings/test_oustring_stringliterals.cxx built with
RTL_STRING_UNITTEST, so have simply been disabled for that special test-code
case.)
Change-Id: Id29799fa8da21a09ff9794cbc7cc9b366e6803b8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122890
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/pkgchk/unopkg/unopkg_app.cxx | 6 | ||||
-rw-r--r-- | desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx | 16 | ||||
-rw-r--r-- | desktop/source/pkgchk/unopkg/unopkg_misc.cxx | 4 |
3 files changed, 13 insertions, 13 deletions
diff --git a/desktop/source/pkgchk/unopkg/unopkg_app.cxx b/desktop/source/pkgchk/unopkg/unopkg_app.cxx index 857902dd4f4e..a28b94b5888d 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_app.cxx +++ b/desktop/source/pkgchk/unopkg/unopkg_app.cxx @@ -271,7 +271,7 @@ extern "C" int unopkg_main() if (cmdArg[ 0 ] == '-') { // is option: - dp_misc::writeConsoleError(OUString( + dp_misc::writeConsoleError(OUStringConcatenation( "\nERROR: unexpected option " + cmdArg + "!\n Use " APP_NAME " " + @@ -478,7 +478,7 @@ extern "C" int unopkg_main() vec_packages.size(), false); dp_misc::writeConsole( - OUString("All deployed " + repository + " extensions:\n\n")); + OUStringConcatenation("All deployed " + repository + " extensions:\n\n")); } else { @@ -612,7 +612,7 @@ extern "C" int unopkg_main() catch (const LockFileException & e) { // No logger since it requires UNO which we don't have here - dp_misc::writeConsoleError(OUString(e.Message + "\n")); + dp_misc::writeConsoleError(OUStringConcatenation(e.Message + "\n")); bShowFailedMsg = false; } catch (const css::uno::Exception & e ) { diff --git a/desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx b/desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx index 2180695d85b7..cca5b7ae3365 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx +++ b/desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx @@ -142,9 +142,9 @@ void CommandEnvironmentImpl::printLicense( OUString sNewLine("\n"); - dp_misc::writeConsole(OUString(sNewLine + sNewLine + s1 + sNewLine + sNewLine)); - dp_misc::writeConsole(OUString(sLicense + sNewLine + sNewLine)); - dp_misc::writeConsole(OUString(s2 + sNewLine)); + dp_misc::writeConsole(OUStringConcatenation(sNewLine + sNewLine + s1 + sNewLine + sNewLine)); + dp_misc::writeConsole(OUStringConcatenation(sLicense + sNewLine + sNewLine)); + dp_misc::writeConsole(OUStringConcatenation(s2 + sNewLine)); dp_misc::writeConsole(s3); //the user may enter "yes" or "no", we compare in a case insensitive way @@ -171,7 +171,7 @@ void CommandEnvironmentImpl::printLicense( } else { - dp_misc::writeConsole(OUString(sNewLine + sNewLine + s4 + sNewLine)); + dp_misc::writeConsole(OUStringConcatenation(sNewLine + sNewLine + s4 + sNewLine)); } } while(true); @@ -257,7 +257,7 @@ void CommandEnvironmentImpl::handle( { OUString sMsg(DpResId(RID_STR_UNSUPPORTED_PLATFORM)); sMsg = sMsg.replaceAll("%Name", platExc.package->getDisplayName()); - dp_misc::writeConsole(OUString("\n" + sMsg + "\n\n")); + dp_misc::writeConsole(OUStringConcatenation("\n" + sMsg + "\n\n")); approve = true; } else { @@ -275,7 +275,7 @@ void CommandEnvironmentImpl::handle( if (abort && m_option_verbose) { OUString msg = ::comphelper::anyToString(request); - dp_misc::writeConsoleError(OUString("\nERROR: " + msg + "\n")); + dp_misc::writeConsoleError(OUStringConcatenation("\nERROR: " + msg + "\n")); } // select: @@ -348,9 +348,9 @@ void CommandEnvironmentImpl::update_( Any const & Status ) } if (bUseErr) - dp_misc::writeConsoleError(OUString(msg + "\n")); + dp_misc::writeConsoleError(OUStringConcatenation(msg + "\n")); else - dp_misc::writeConsole(OUString(msg + "\n")); + dp_misc::writeConsole(OUStringConcatenation(msg + "\n")); } diff --git a/desktop/source/pkgchk/unopkg/unopkg_misc.cxx b/desktop/source/pkgchk/unopkg/unopkg_misc.cxx index c2152928ceb2..402833aa5019 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_misc.cxx +++ b/desktop/source/pkgchk/unopkg/unopkg_misc.cxx @@ -229,7 +229,7 @@ void printf_line( std::u16string_view name, std::u16string_view value, sal_Int32 level ) { printf_space( level ); - dp_misc::writeConsole(OUString(OUString::Concat(name) + ": " + value + "\n")); + dp_misc::writeConsole(OUStringConcatenation(OUString::Concat(name) + ": " + value + "\n")); } @@ -359,7 +359,7 @@ Reference<XComponentContext> connectToOffice( if (verbose) { - dp_misc::writeConsole(OUString( + dp_misc::writeConsole(OUStringConcatenation( "Raising process: " + appURL + "\nArguments: --nologo --nodefault " + args[2] + "\n")); |