diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-12-17 22:02:06 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-12-19 17:53:06 +0100 |
commit | 46c5de832868d2812448b2caace3eeaa9237b9f6 (patch) | |
tree | 6f25538cfb7a0def54ff7ac5b6b17eb22a76178a /sfx2 | |
parent | 6dd1d2268487920e8bda44dfd169a5bda4d62f13 (diff) |
make *String(string_view) constructors explicit
to make it more obvious when we are constructing heap OUStrings
code and potentially inadvertently throwing away performance.
And fix a handful of places so revealed.
Change-Id: I0cf390f78026f8a670aaab53424cd31510633051
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107923
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/dialog/filedlghelper.cxx | 22 | ||||
-rw-r--r-- | sfx2/source/doc/objmisc.cxx | 2 |
2 files changed, 11 insertions, 13 deletions
diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 1b39b59bf0c8..b876fd1a9082 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -123,23 +123,21 @@ namespace } } -static const std::u16string_view* GetLastFilterConfigId( FileDialogHelper::Context _eContext ) +static std::optional<OUString> GetLastFilterConfigId( FileDialogHelper::Context _eContext ) { - static const std::u16string_view aSD_EXPORT_IDENTIFIER(u"SdExportLastFilter"); - static const std::u16string_view aSI_EXPORT_IDENTIFIER(u"SiExportLastFilter"); - static const std::u16string_view aSW_EXPORT_IDENTIFIER(u"SwExportLastFilter"); - - const std::u16string_view* pRet = nullptr; + static const OUStringLiteral aSD_EXPORT_IDENTIFIER(u"SdExportLastFilter"); + static const OUStringLiteral aSI_EXPORT_IDENTIFIER(u"SiExportLastFilter"); + static const OUStringLiteral aSW_EXPORT_IDENTIFIER(u"SwExportLastFilter"); switch( _eContext ) { - case FileDialogHelper::SD_EXPORT: pRet = &aSD_EXPORT_IDENTIFIER; break; - case FileDialogHelper::SI_EXPORT: pRet = &aSI_EXPORT_IDENTIFIER; break; - case FileDialogHelper::SW_EXPORT: pRet = &aSW_EXPORT_IDENTIFIER; break; + case FileDialogHelper::SD_EXPORT: return aSD_EXPORT_IDENTIFIER; + case FileDialogHelper::SI_EXPORT: return aSI_EXPORT_IDENTIFIER; + case FileDialogHelper::SW_EXPORT: return aSW_EXPORT_IDENTIFIER; default: break; } - return pRet; + return {}; } static OUString EncodeSpaces_Impl( const OUString& rSource ); @@ -346,7 +344,7 @@ void FileDialogHelper_Impl::LoadLastUsedFilter( const OUString& _rContextIdentif void FileDialogHelper_Impl::SaveLastUsedFilter() { - const std::u16string_view* pConfigId = GetLastFilterConfigId( meContext ); + std::optional<OUString> pConfigId = GetLastFilterConfigId( meContext ); if( pConfigId ) SvtViewOptions( EViewType::Dialog, IODLG_CONFIGNAME ).SetUserItem( *pConfigId, makeAny( getFilterWithExtension( getFilter() ) ) ); @@ -2250,7 +2248,7 @@ void FileDialogHelper_Impl::SetContext( FileDialogHelper::Context _eNewContext ) { meContext = _eNewContext; - const std::u16string_view* pConfigId = GetLastFilterConfigId( _eNewContext ); + std::optional<OUString> pConfigId = GetLastFilterConfigId( _eNewContext ); if( pConfigId ) LoadLastUsedFilter( *pConfigId ); } diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index 8e5fbd4df93d..d59d334bd55b 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -1322,7 +1322,7 @@ ErrCode SfxObjectShell::CallBasic( std::u16string_view rMacro, BasicManager *pMgr = GetBasicManager(); if( pApp->GetName() == rBasic ) pMgr = SfxApplication::GetBasicManager(); - ErrCode nRet = SfxApplication::CallBasic( rMacro, pMgr, pArgs, pRet ); + ErrCode nRet = SfxApplication::CallBasic( OUString(rMacro), pMgr, pArgs, pRet ); return nRet; } |