From 86a32589e90ee983159fb5b2c6a594428ab7d422 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 6 Mar 2014 15:29:08 +0200 Subject: Find places where OUString and OString are passed by value. It's not very efficient, because we generally end up copying it twice - once into the parameter and again into the destination OUString. So I create a clang plugin that finds such places and generates a warning so that we can convert them to pass-by-reference. Change-Id: I5341a6ea9e3190f4b4c05c42c85595e3dcd83361 --- package/source/xstor/xstorage.cxx | 10 +++++----- package/source/xstor/xstorage.hxx | 10 +++++----- package/source/zipapi/ZipFile.cxx | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'package/source') diff --git a/package/source/xstor/xstorage.cxx b/package/source/xstor/xstorage.cxx index 1c00a5d68dc8..c3a621279cc6 100644 --- a/package/source/xstor/xstorage.cxx +++ b/package/source/xstor/xstorage.cxx @@ -776,7 +776,7 @@ void OStorage_Impl::CopyToStorage( const uno::Reference< embed::XStorage >& xDes void OStorage_Impl::CopyStorageElement( SotElement_Impl* pElement, uno::Reference< embed::XStorage > xDest, - OUString aName, + const OUString& aName, sal_Bool bDirect ) { SAL_WARN_IF( !xDest.is(), "package.xstor", "No destination storage!" ); @@ -1384,7 +1384,7 @@ SotElement_Impl* OStorage_Impl::FindElement( const OUString& rName ) return NULL; } -SotElement_Impl* OStorage_Impl::InsertStream( OUString aName, sal_Bool bEncr ) +SotElement_Impl* OStorage_Impl::InsertStream( const OUString& aName, sal_Bool bEncr ) { SAL_WARN_IF( !m_xPackage.is(), "package.xstor", "Not possible to refer to package as to factory!" ); if ( !m_xPackage.is() ) @@ -1418,7 +1418,7 @@ SotElement_Impl* OStorage_Impl::InsertStream( OUString aName, sal_Bool bEncr ) return pNewElement; } -SotElement_Impl* OStorage_Impl::InsertRawStream( OUString aName, const uno::Reference< io::XInputStream >& xInStream ) +SotElement_Impl* OStorage_Impl::InsertRawStream( const OUString& aName, const uno::Reference< io::XInputStream >& xInStream ) { // insert of raw stream means insert and commit SAL_WARN_IF( !m_xPackage.is(), "package.xstor", "Not possible to refer to package as to factory!" ); @@ -1486,7 +1486,7 @@ OStorage_Impl* OStorage_Impl::CreateNewStorageImpl( sal_Int32 nStorageMode ) return pResult; } -SotElement_Impl* OStorage_Impl::InsertStorage( OUString aName, sal_Int32 nStorageMode ) +SotElement_Impl* OStorage_Impl::InsertStorage( const OUString& aName, sal_Int32 nStorageMode ) { SotElement_Impl* pNewElement = InsertElement( aName, sal_True ); @@ -1497,7 +1497,7 @@ SotElement_Impl* OStorage_Impl::InsertStorage( OUString aName, sal_Int32 nStorag return pNewElement; } -SotElement_Impl* OStorage_Impl::InsertElement( OUString aName, sal_Bool bIsStorage ) +SotElement_Impl* OStorage_Impl::InsertElement( const OUString& aName, sal_Bool bIsStorage ) { OSL_ENSURE( FindElement( aName ) == NULL, "Should not try to insert existing element" ); diff --git a/package/source/xstor/xstorage.hxx b/package/source/xstor/xstorage.hxx index 53883be585ee..3e968e29c3d6 100644 --- a/package/source/xstor/xstorage.hxx +++ b/package/source/xstor/xstorage.hxx @@ -232,19 +232,19 @@ struct OStorage_Impl sal_Bool bDirect ); void CopyStorageElement( SotElement_Impl* pElement, ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > xDest, - OUString aName, + const OUString& aName, sal_Bool bDirect ); void SetModified( sal_Bool bModified ); SotElement_Impl* FindElement( const OUString& rName ); - SotElement_Impl* InsertStream( OUString aName, sal_Bool bEncr ); - SotElement_Impl* InsertRawStream( OUString aName, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInStream ); + SotElement_Impl* InsertStream( const OUString& aName, sal_Bool bEncr ); + SotElement_Impl* InsertRawStream( const OUString& aName, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInStream ); OStorage_Impl* CreateNewStorageImpl( sal_Int32 nStorageMode ); - SotElement_Impl* InsertStorage( OUString aName, sal_Int32 nStorageMode ); - SotElement_Impl* InsertElement( OUString aName, sal_Bool bIsStorage ); + SotElement_Impl* InsertStorage( const OUString& aName, sal_Int32 nStorageMode ); + SotElement_Impl* InsertElement( const OUString& aName, sal_Bool bIsStorage ); void OpenSubStorage( SotElement_Impl* pElement, sal_Int32 nStorageMode ); void OpenSubStream( SotElement_Impl* pElement ); diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx index 76ff293aa926..72551857dbdf 100644 --- a/package/source/zipapi/ZipFile.cxx +++ b/package/source/zipapi/ZipFile.cxx @@ -518,7 +518,7 @@ uno::Reference< XInputStream > ZipFile::createUnbufferedStream( const ::rtl::Reference< EncryptionData > &rData, sal_Int8 nStreamMode, sal_Bool bIsEncrypted, - OUString aMediaType ) + const OUString& aMediaType ) { ::osl::MutexGuard aGuard( m_aMutex ); -- cgit v1.2.3