summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-05-15 13:02:18 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-05-15 21:40:17 +0200
commitc5340bdf444ae74f3778a2cf9f90d5db6c9ef153 (patch)
treed950be08fcbc56cbf8f14a52656e28de77e49bf8
parentcc4325f84a0ba35d8bbb564512bce0c6b8aab408 (diff)
cache string in DocInfoHelper::GetGeneratorString
since it doesn't change Change-Id: I8a9eee18b6de5f375ee2d4d67cdf48700590d007 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134347 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--unotools/source/config/docinfohelper.cxx118
1 files changed, 61 insertions, 57 deletions
diff --git a/unotools/source/config/docinfohelper.cxx b/unotools/source/config/docinfohelper.cxx
index 735f0ac2d56e..6b36fb21b7e3 100644
--- a/unotools/source/config/docinfohelper.cxx
+++ b/unotools/source/config/docinfohelper.cxx
@@ -31,74 +31,78 @@ namespace utl
OUString DocInfoHelper::GetGeneratorString()
{
- OUString aResultOverride = officecfg::Office::Common::Save::Document::GeneratorOverride::get();
- if( !aResultOverride.isEmpty())
- return aResultOverride;
-
- OUStringBuffer aResult(128);
-
- // First product: branded name + version
- // version is <product_versions>_<product_extension>$<platform>
+ static const OUString sGenerator = []()
+ {
+ OUString aResultOverride = officecfg::Office::Common::Save::Document::GeneratorOverride::get();
+ if( !aResultOverride.isEmpty())
+ return aResultOverride;
- // plain product name
- OUString aValue( utl::ConfigManager::getProductName() );
- if ( !aValue.isEmpty() )
- {
- aResult.append( aValue.replace( ' ', '_' ) );
- aResult.append( '/' );
+ OUStringBuffer aResult(128);
- aValue = utl::ConfigManager::getProductVersion();
- if ( !aValue.isEmpty() )
- {
- aResult.append( aValue.replace( ' ', '_' ) );
+ // First product: branded name + version
+ // version is <product_versions>_<product_extension>$<platform>
- aValue = utl::ConfigManager::getProductExtension();
+ // plain product name
+ OUString aValue( utl::ConfigManager::getProductName() );
if ( !aValue.isEmpty() )
{
aResult.append( aValue.replace( ' ', '_' ) );
- }
- }
+ aResult.append( '/' );
- OUString os( "$_OS" );
- OUString arch( "$_ARCH" );
- ::rtl::Bootstrap::expandMacros(os);
- ::rtl::Bootstrap::expandMacros(arch);
- aResult.append( '$' );
- aResult.append( os );
- aResult.append( '_' );
- aResult.append( arch );
- aResult.append( ' ' );
- }
+ aValue = utl::ConfigManager::getProductVersion();
+ if ( !aValue.isEmpty() )
+ {
+ aResult.append( aValue.replace( ' ', '_' ) );
- // second product: LibreOffice_project/<build_information>
- // build_information has '(' and '[' encoded as '$', ')' and ']' ignored
- // and ':' replaced by '-'
- {
- aResult.append( "LibreOffice_project/" );
- OUString aBuildId( Bootstrap::getBuildIdData( OUString() ) );
- for( sal_Int32 i=0; i < aBuildId.getLength(); i++ )
- {
- sal_Unicode c = aBuildId[i];
- switch( c )
- {
- case '(':
- case '[':
+ aValue = utl::ConfigManager::getProductExtension();
+ if ( !aValue.isEmpty() )
+ {
+ aResult.append( aValue.replace( ' ', '_' ) );
+ }
+ }
+
+ OUString os( "$_OS" );
+ OUString arch( "$_ARCH" );
+ ::rtl::Bootstrap::expandMacros(os);
+ ::rtl::Bootstrap::expandMacros(arch);
aResult.append( '$' );
- break;
- case ')':
- case ']':
- break;
- case ':':
- aResult.append( '-' );
- break;
- default:
- aResult.append( c );
- break;
+ aResult.append( os );
+ aResult.append( '_' );
+ aResult.append( arch );
+ aResult.append( ' ' );
+ }
+
+ // second product: LibreOffice_project/<build_information>
+ // build_information has '(' and '[' encoded as '$', ')' and ']' ignored
+ // and ':' replaced by '-'
+ {
+ aResult.append( "LibreOffice_project/" );
+ OUString aBuildId( Bootstrap::getBuildIdData( OUString() ) );
+ for( sal_Int32 i=0; i < aBuildId.getLength(); i++ )
+ {
+ sal_Unicode c = aBuildId[i];
+ switch( c )
+ {
+ case '(':
+ case '[':
+ aResult.append( '$' );
+ break;
+ case ')':
+ case ']':
+ break;
+ case ':':
+ aResult.append( '-' );
+ break;
+ default:
+ aResult.append( c );
+ break;
+ }
+ }
}
- }
- }
- return aResult.makeStringAndClear();
+ return aResult.makeStringAndClear();
+ }();
+ return sGenerator;
}
} // end of namespace utl