diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-06-23 12:34:31 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-06-26 13:12:31 +0200 |
commit | 0193b284e880a659ab73160e42238e1d5fe5cf8f (patch) | |
tree | da09299838a6afb43d7c601803a6bab787489854 /package | |
parent | 2ef138de767c312188d41a7f206234eafac3108b (diff) |
new loplugin:constexprliteral
OUStringLiteral should be declared constexpr, to enforce
that it is initialised at compile-time and not runtime.
This seems to make a different at least on Visual Studio
Change-Id: I1698f5fa22ddb480347c2f4d444530c2e0e88d92
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153499
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'package')
-rw-r--r-- | package/source/manifest/ManifestExport.cxx | 36 | ||||
-rw-r--r-- | package/source/zippackage/ZipPackage.cxx | 38 | ||||
-rw-r--r-- | package/source/zippackage/ZipPackageStream.cxx | 10 |
3 files changed, 42 insertions, 42 deletions
diff --git a/package/source/manifest/ManifestExport.cxx b/package/source/manifest/ManifestExport.cxx index 938a33526d3c..79948c9ff068 100644 --- a/package/source/manifest/ManifestExport.cxx +++ b/package/source/manifest/ManifestExport.cxx @@ -45,24 +45,24 @@ using namespace ::com::sun::star; ManifestExport::ManifestExport( uno::Reference< xml::sax::XDocumentHandler > const & xHandler, const uno::Sequence< uno::Sequence < beans::PropertyValue > >& rManList ) { - static const OUStringLiteral sKeyInfo ( u"KeyInfo" ); - static const OUStringLiteral sPgpKeyIDProperty ( u"KeyId" ); - static const OUStringLiteral sPgpKeyPacketProperty ( u"KeyPacket" ); - static const OUStringLiteral sCipherValueProperty ( u"CipherValue" ); - static const OUStringLiteral sFullPathProperty ( u"FullPath" ); - static const OUStringLiteral sVersionProperty ( u"Version" ); - static const OUStringLiteral sMediaTypeProperty ( u"MediaType" ); - static const OUStringLiteral sIterationCountProperty ( u"IterationCount" ); - static const OUStringLiteral sDerivedKeySizeProperty ( u"DerivedKeySize" ); - static const OUStringLiteral sSaltProperty ( u"Salt" ); - static const OUStringLiteral sInitialisationVectorProperty( u"InitialisationVector" ); - static const OUStringLiteral sSizeProperty ( u"Size" ); - static const OUStringLiteral sDigestProperty ( u"Digest" ); - static const OUStringLiteral sEncryptionAlgProperty ( u"EncryptionAlgorithm" ); - static const OUStringLiteral sStartKeyAlgProperty ( u"StartKeyAlgorithm" ); - static const OUStringLiteral sDigestAlgProperty ( u"DigestAlgorithm" ); - - static const OUStringLiteral sWhiteSpace ( u" " ); + static constexpr OUStringLiteral sKeyInfo ( u"KeyInfo" ); + static constexpr OUStringLiteral sPgpKeyIDProperty ( u"KeyId" ); + static constexpr OUStringLiteral sPgpKeyPacketProperty ( u"KeyPacket" ); + static constexpr OUStringLiteral sCipherValueProperty ( u"CipherValue" ); + static constexpr OUStringLiteral sFullPathProperty ( u"FullPath" ); + static constexpr OUStringLiteral sVersionProperty ( u"Version" ); + static constexpr OUStringLiteral sMediaTypeProperty ( u"MediaType" ); + static constexpr OUStringLiteral sIterationCountProperty ( u"IterationCount" ); + static constexpr OUStringLiteral sDerivedKeySizeProperty ( u"DerivedKeySize" ); + static constexpr OUStringLiteral sSaltProperty ( u"Salt" ); + static constexpr OUStringLiteral sInitialisationVectorProperty( u"InitialisationVector" ); + static constexpr OUStringLiteral sSizeProperty ( u"Size" ); + static constexpr OUStringLiteral sDigestProperty ( u"Digest" ); + static constexpr OUStringLiteral sEncryptionAlgProperty ( u"EncryptionAlgorithm" ); + static constexpr OUStringLiteral sStartKeyAlgProperty ( u"StartKeyAlgorithm" ); + static constexpr OUStringLiteral sDigestAlgProperty ( u"DigestAlgorithm" ); + + static constexpr OUStringLiteral sWhiteSpace ( u" " ); const OUString sSHA256_URL_ODF12 ( SHA256_URL_ODF12 ); const OUString sSHA1_Name ( SHA1_NAME ); diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx index 9c841ec58bc6..1ba45654b73c 100644 --- a/package/source/zippackage/ZipPackage.cxx +++ b/package/source/zippackage/ZipPackage.cxx @@ -168,11 +168,11 @@ void ZipPackage::parseManifest() return; bool bManifestParsed = false; - static const OUStringLiteral sMeta (u"META-INF"); + static constexpr OUStringLiteral sMeta (u"META-INF"); if ( m_xRootFolder->hasByName( sMeta ) ) { try { - static const OUStringLiteral sManifest (u"manifest.xml"); + static constexpr OUStringLiteral sManifest (u"manifest.xml"); Any aAny = m_xRootFolder->getByName( sMeta ); uno::Reference< XNameContainer > xMetaInfFolder; aAny >>= xMetaInfFolder; @@ -185,19 +185,19 @@ void ZipPackage::parseManifest() { uno::Reference < XManifestReader > xReader = ManifestReader::create( m_xContext ); - static const OUStringLiteral sPropFullPath (u"FullPath"); - static const OUStringLiteral sPropVersion (u"Version"); - static const OUStringLiteral sPropMediaType (u"MediaType"); - static const OUStringLiteral sPropInitialisationVector (u"InitialisationVector"); - static const OUStringLiteral sPropSalt (u"Salt"); - static const OUStringLiteral sPropIterationCount (u"IterationCount"); - static const OUStringLiteral sPropSize (u"Size"); - static const OUStringLiteral sPropDigest (u"Digest"); - static const OUStringLiteral sPropDerivedKeySize (u"DerivedKeySize"); - static const OUStringLiteral sPropDigestAlgorithm (u"DigestAlgorithm"); - static const OUStringLiteral sPropEncryptionAlgorithm (u"EncryptionAlgorithm"); - static const OUStringLiteral sPropStartKeyAlgorithm (u"StartKeyAlgorithm"); - static const OUStringLiteral sKeyInfo (u"KeyInfo"); + static constexpr OUStringLiteral sPropFullPath (u"FullPath"); + static constexpr OUStringLiteral sPropVersion (u"Version"); + static constexpr OUStringLiteral sPropMediaType (u"MediaType"); + static constexpr OUStringLiteral sPropInitialisationVector (u"InitialisationVector"); + static constexpr OUStringLiteral sPropSalt (u"Salt"); + static constexpr OUStringLiteral sPropIterationCount (u"IterationCount"); + static constexpr OUStringLiteral sPropSize (u"Size"); + static constexpr OUStringLiteral sPropDigest (u"Digest"); + static constexpr OUStringLiteral sPropDerivedKeySize (u"DerivedKeySize"); + static constexpr OUStringLiteral sPropDigestAlgorithm (u"DigestAlgorithm"); + static constexpr OUStringLiteral sPropEncryptionAlgorithm (u"EncryptionAlgorithm"); + static constexpr OUStringLiteral sPropStartKeyAlgorithm (u"StartKeyAlgorithm"); + static constexpr OUStringLiteral sKeyInfo (u"KeyInfo"); const uno::Sequence < uno::Sequence < PropertyValue > > aManifestSequence = xReader->readManifestSequence ( xSink->getInputStream() ); const Any *pKeyInfo = nullptr; @@ -370,7 +370,7 @@ void ZipPackage::parseManifest() throw ZipIOException( THROW_WHERE "Could not parse manifest.xml" ); - static const OUStringLiteral sMimetype (u"mimetype"); + static constexpr OUStringLiteral sMimetype (u"mimetype"); if ( m_xRootFolder->hasByName( sMimetype ) ) { // get mediatype from the "mimetype" stream @@ -447,7 +447,7 @@ void ZipPackage::parseContentType() return; try { - static const OUStringLiteral aContentTypes(u"[Content_Types].xml"); + static constexpr OUStringLiteral aContentTypes(u"[Content_Types].xml"); // the content type must exist in OFOPXML format! if ( !m_xRootFolder->hasByName( aContentTypes ) ) throw io::IOException(THROW_WHERE "Wrong format!" ); @@ -1001,7 +1001,7 @@ uno::Reference< XInterface > SAL_CALL ZipPackage::createInstanceWithArguments( c void ZipPackage::WriteMimetypeMagicFile( ZipOutputStream& aZipOut ) { - static const OUStringLiteral sMime (u"mimetype"); + static constexpr OUStringLiteral sMime (u"mimetype"); if ( m_xRootFolder->hasByName( sMime ) ) m_xRootFolder->removeByName( sMime ); @@ -1214,7 +1214,7 @@ uno::Reference< io::XInputStream > ZipPackage::writeTempFile() if ( m_xRootFolder->hasByName( sMeta ) ) { - static const OUStringLiteral sManifest (u"manifest.xml"); + static constexpr OUStringLiteral sManifest (u"manifest.xml"); uno::Reference< XNameContainer > xMetaInfFolder; Any aAny = m_xRootFolder->getByName( sMeta ); diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx index 353216694f8a..6af3480d9e02 100644 --- a/package/source/zippackage/ZipPackageStream.cxx +++ b/package/source/zippackage/ZipPackageStream.cxx @@ -435,11 +435,11 @@ bool ZipPackageStream::saveChild( { bool bSuccess = true; - static const OUStringLiteral sDigestProperty (u"Digest"); - static const OUStringLiteral sEncryptionAlgProperty (u"EncryptionAlgorithm"); - static const OUStringLiteral sStartKeyAlgProperty (u"StartKeyAlgorithm"); - static const OUStringLiteral sDigestAlgProperty (u"DigestAlgorithm"); - static const OUStringLiteral sDerivedKeySizeProperty (u"DerivedKeySize"); + static constexpr OUStringLiteral sDigestProperty (u"Digest"); + static constexpr OUStringLiteral sEncryptionAlgProperty (u"EncryptionAlgorithm"); + static constexpr OUStringLiteral sStartKeyAlgProperty (u"StartKeyAlgorithm"); + static constexpr OUStringLiteral sDigestAlgProperty (u"DigestAlgorithm"); + static constexpr OUStringLiteral sDerivedKeySizeProperty (u"DerivedKeySize"); uno::Sequence < beans::PropertyValue > aPropSet (PKG_SIZE_NOENCR_MNFST); |