From 04c62acc63a88e668edea67ea6dd2127858e25be Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Sat, 7 Dec 2024 17:23:17 +0500 Subject: [PATCH] Use std::initializer_list, C-style array instead of more expensive Sequence Change-Id: Ibb268268926cc91f595f19026f6cee4b5a74a8bc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178038 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- accessibility/source/standard/vclxaccessiblecombobox.cxx | 2 +- .../source/standard/vclxaccessibledropdowncombobox.cxx | 2 +- .../source/standard/vclxaccessibledropdownlistbox.cxx | 2 +- accessibility/source/standard/vclxaccessiblelist.cxx | 2 +- accessibility/source/standard/vclxaccessiblelistbox.cxx | 2 +- accessibility/source/standard/vclxaccessibletextfield.cxx | 2 +- accessibility/source/standard/vclxaccessibletoolbox.cxx | 2 +- comphelper/source/misc/proxyaggregation.cxx | 2 +- connectivity/source/drivers/jdbc/CallableStatement.cxx | 6 +++--- editeng/source/uno/unofield.cxx | 2 +- forms/source/component/DatabaseForm.cxx | 6 +++--- forms/source/component/Date.cxx | 2 +- forms/source/component/File.cxx | 2 +- forms/source/component/FormComponent.cxx | 2 +- forms/source/component/scrollbar.cxx | 2 +- forms/source/component/spinbutton.cxx | 2 +- forms/source/richtext/richtextmodel.cxx | 2 +- svx/source/form/fmdmod.cxx | 6 +----- svx/source/form/formcontroller.cxx | 2 +- svx/source/table/cell.cxx | 2 +- svx/source/unodraw/unomod.cxx | 2 +- 21 files changed, 25 insertions(+), 29 deletions(-) diff --git a/accessibility/source/standard/vclxaccessiblecombobox.cxx b/accessibility/source/standard/vclxaccessiblecombobox.cxx index 5e0c77304ad8..1673048cf771 100644 --- a/accessibility/source/standard/vclxaccessiblecombobox.cxx +++ b/accessibility/source/standard/vclxaccessiblecombobox.cxx @@ -41,7 +41,7 @@ OUString VCLXAccessibleComboBox::getImplementationName() Sequence< OUString > VCLXAccessibleComboBox::getSupportedServiceNames() { return comphelper::concatSequences(VCLXAccessibleBox::getSupportedServiceNames(), - Sequence{u"com.sun.star.accessibility.AccessibleComboBox"_ustr}); + std::initializer_list{u"com.sun.star.accessibility.AccessibleComboBox"_ustr}); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/accessibility/source/standard/vclxaccessibledropdowncombobox.cxx b/accessibility/source/standard/vclxaccessibledropdowncombobox.cxx index 5dc7073e7f0b..91b51606d9e0 100644 --- a/accessibility/source/standard/vclxaccessibledropdowncombobox.cxx +++ b/accessibility/source/standard/vclxaccessibledropdowncombobox.cxx @@ -60,7 +60,7 @@ OUString VCLXAccessibleDropDownComboBox::getImplementationName() Sequence< OUString > VCLXAccessibleDropDownComboBox::getSupportedServiceNames() { return comphelper::concatSequences(VCLXAccessibleBox::getSupportedServiceNames(), - Sequence{u"com.sun.star.accessibility.AccessibleDropDownComboBox"_ustr}); + std::initializer_list{u"com.sun.star.accessibility.AccessibleDropDownComboBox"_ustr}); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/accessibility/source/standard/vclxaccessibledropdownlistbox.cxx b/accessibility/source/standard/vclxaccessibledropdownlistbox.cxx index 360eab0dc26c..0445e39b2d29 100644 --- a/accessibility/source/standard/vclxaccessibledropdownlistbox.cxx +++ b/accessibility/source/standard/vclxaccessibledropdownlistbox.cxx @@ -39,7 +39,7 @@ OUString VCLXAccessibleDropDownListBox::getImplementationName() Sequence< OUString > VCLXAccessibleDropDownListBox::getSupportedServiceNames() { return comphelper::concatSequences(VCLXAccessibleBox::getSupportedServiceNames(), - Sequence{u"com.sun.star.accessibility.AccessibleDropDownListBox"_ustr}); + std::initializer_list{u"com.sun.star.accessibility.AccessibleDropDownListBox"_ustr}); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/accessibility/source/standard/vclxaccessiblelist.cxx b/accessibility/source/standard/vclxaccessiblelist.cxx index d84a631687fc..79cb5241d567 100644 --- a/accessibility/source/standard/vclxaccessiblelist.cxx +++ b/accessibility/source/standard/vclxaccessiblelist.cxx @@ -602,7 +602,7 @@ OUString VCLXAccessibleList::getImplementationName() Sequence< OUString > VCLXAccessibleList::getSupportedServiceNames() { return comphelper::concatSequences(VCLXAccessibleComponent::getSupportedServiceNames(), - Sequence{u"com.sun.star.accessibility.AccessibleList"_ustr}); + std::initializer_list{u"com.sun.star.accessibility.AccessibleList"_ustr}); } void VCLXAccessibleList::UpdateVisibleLineCount() diff --git a/accessibility/source/standard/vclxaccessiblelistbox.cxx b/accessibility/source/standard/vclxaccessiblelistbox.cxx index 2f9392ab0341..de282aba1a64 100644 --- a/accessibility/source/standard/vclxaccessiblelistbox.cxx +++ b/accessibility/source/standard/vclxaccessiblelistbox.cxx @@ -40,7 +40,7 @@ OUString VCLXAccessibleListBox::getImplementationName() Sequence< OUString > VCLXAccessibleListBox::getSupportedServiceNames() { return comphelper::concatSequences(VCLXAccessibleBox::getSupportedServiceNames(), - Sequence{u"com.sun.star.accessibility.AccessibleListBox"_ustr}); + std::initializer_list{u"com.sun.star.accessibility.AccessibleListBox"_ustr}); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/accessibility/source/standard/vclxaccessibletextfield.cxx b/accessibility/source/standard/vclxaccessibletextfield.cxx index 4f43656419b0..238a7f1a670f 100644 --- a/accessibility/source/standard/vclxaccessibletextfield.cxx +++ b/accessibility/source/standard/vclxaccessibletextfield.cxx @@ -96,7 +96,7 @@ OUString VCLXAccessibleTextField::getImplementationName() Sequence< OUString > VCLXAccessibleTextField::getSupportedServiceNames() { return comphelper::concatSequences(VCLXAccessibleTextComponent::getSupportedServiceNames(), - Sequence{u"com.sun.star.accessibility.AccessibleTextField"_ustr}); + std::initializer_list{u"com.sun.star.accessibility.AccessibleTextField"_ustr}); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/accessibility/source/standard/vclxaccessibletoolbox.cxx b/accessibility/source/standard/vclxaccessibletoolbox.cxx index d2a1e8d23e27..c8601d707ad3 100644 --- a/accessibility/source/standard/vclxaccessibletoolbox.cxx +++ b/accessibility/source/standard/vclxaccessibletoolbox.cxx @@ -589,7 +589,7 @@ OUString VCLXAccessibleToolBox::getImplementationName() Sequence< OUString > VCLXAccessibleToolBox::getSupportedServiceNames() { return comphelper::concatSequences(VCLXAccessibleComponent::getSupportedServiceNames(), - Sequence{u"com.sun.star.accessibility.AccessibleToolBox"_ustr}); + std::initializer_list{u"com.sun.star.accessibility.AccessibleToolBox"_ustr}); } // XAccessibleContext diff --git a/comphelper/source/misc/proxyaggregation.cxx b/comphelper/source/misc/proxyaggregation.cxx index db580bea496c..b24629d5614a 100644 --- a/comphelper/source/misc/proxyaggregation.cxx +++ b/comphelper/source/misc/proxyaggregation.cxx @@ -208,7 +208,7 @@ namespace comphelper return comphelper::concatSequences( OComponentProxyAggregationHelper::getTypes(), // append XComponent, coming from WeakComponentImplHelperBase - Sequence { cppu::UnoType::get() }); + std::initializer_list{ cppu::UnoType::get() }); } diff --git a/connectivity/source/drivers/jdbc/CallableStatement.cxx b/connectivity/source/drivers/jdbc/CallableStatement.cxx index f98dbe337888..6c1714e06352 100644 --- a/connectivity/source/drivers/jdbc/CallableStatement.cxx +++ b/connectivity/source/drivers/jdbc/CallableStatement.cxx @@ -61,10 +61,10 @@ Any SAL_CALL java_sql_CallableStatement::queryInterface( const Type & rType ) css::uno::Sequence< css::uno::Type > SAL_CALL java_sql_CallableStatement::getTypes( ) { - ::cppu::OTypeCollection aTypes( cppu::UnoType::get(), - cppu::UnoType::get()); + css::uno::Type aTypes[] { cppu::UnoType::get(), + cppu::UnoType::get() }; - return ::comphelper::concatSequences(aTypes.getTypes(),java_sql_PreparedStatement::getTypes()); + return ::comphelper::concatSequences(java_sql_PreparedStatement::getTypes(), aTypes); } sal_Bool SAL_CALL java_sql_CallableStatement::wasNull( ) diff --git a/editeng/source/uno/unofield.cxx b/editeng/source/uno/unofield.cxx index cc2eb9b6367c..cb5000f5ae92 100644 --- a/editeng/source/uno/unofield.cxx +++ b/editeng/source/uno/unofield.cxx @@ -550,7 +550,7 @@ uno::Sequence< uno::Type > SAL_CALL SvxUnoTextField::getTypes() { maTypeSequence = comphelper::concatSequences( OComponentHelper::getTypes(), - uno::Sequence { + std::initializer_list{ cppu::UnoType::get(), cppu::UnoType::get(), cppu::UnoType::get(), diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx index 7cc92ac11c32..999bc986bf07 100644 --- a/forms/source/component/DatabaseForm.cxx +++ b/forms/source/component/DatabaseForm.cxx @@ -3717,11 +3717,11 @@ Sequence< OUString > SAL_CALL ODatabaseForm::getSupportedServiceNames() // concat without own services return ::comphelper::concatSequences( - css::uno::Sequence { + aServices, + std::initializer_list{ FRM_SUN_FORMCOMPONENT, u"com.sun.star.form.FormComponents"_ustr, FRM_SUN_COMPONENT_FORM, FRM_SUN_COMPONENT_HTMLFORM, - FRM_SUN_COMPONENT_DATAFORM, FRM_COMPONENT_FORM }, - aServices + FRM_SUN_COMPONENT_DATAFORM, FRM_COMPONENT_FORM } ); } diff --git a/forms/source/component/Date.cxx b/forms/source/component/Date.cxx index 6958a2b3b40b..16cfa00c139d 100644 --- a/forms/source/component/Date.cxx +++ b/forms/source/component/Date.cxx @@ -119,7 +119,7 @@ css::uno::Reference< css::util::XCloneable > SAL_CALL ODateModel::createClone() css::uno::Sequence SAL_CALL ODateModel::getSupportedServiceNames() { - const css::uno::Sequence vals { + static constexpr OUString vals[] { BINDABLE_CONTROL_MODEL, DATA_AWARE_CONTROL_MODEL, VALIDATABLE_CONTROL_MODEL, diff --git a/forms/source/component/File.cxx b/forms/source/component/File.cxx index a4533403c129..ac7c2816da68 100644 --- a/forms/source/component/File.cxx +++ b/forms/source/component/File.cxx @@ -48,7 +48,7 @@ using namespace ::com::sun::star::util; Sequence OFileControlModel::_getTypes() { static Sequence const aTypes = - concatSequences(OControlModel::_getTypes(), Sequence{ cppu::UnoType::get() }); + concatSequences(OControlModel::_getTypes(), std::initializer_list{ cppu::UnoType::get() }); return aTypes; } diff --git a/forms/source/component/FormComponent.cxx b/forms/source/component/FormComponent.cxx index b36329283262..74d46b8c0a83 100644 --- a/forms/source/component/FormComponent.cxx +++ b/forms/source/component/FormComponent.cxx @@ -1508,7 +1508,7 @@ css::uno::Sequence SAL_CALL OBoundControlModel::getSupportedServiceNam Sequence< OUString > OBoundControlModel::getSupportedServiceNames_Static() { - Sequence aOwnServiceNames { u"com.sun.star.form.DataAwareControlModel"_ustr }; + static constexpr OUString aOwnServiceNames[] { u"com.sun.star.form.DataAwareControlModel"_ustr }; return ::comphelper::concatSequences( OControlModel::getSupportedServiceNames_Static(), aOwnServiceNames diff --git a/forms/source/component/scrollbar.cxx b/forms/source/component/scrollbar.cxx index edf44e1a56d9..4eb5786f9fed 100644 --- a/forms/source/component/scrollbar.cxx +++ b/forms/source/component/scrollbar.cxx @@ -120,7 +120,7 @@ namespace frm // to benefit from the functionality for binding to spreadsheet cells Sequence< OUString > SAL_CALL OScrollBarModel::getSupportedServiceNames() { - Sequence< OUString > aOwnNames { FRM_SUN_COMPONENT_SCROLLBAR, BINDABLE_INTEGER_VALUE_RANGE }; + static constexpr OUString aOwnNames[] { FRM_SUN_COMPONENT_SCROLLBAR, BINDABLE_INTEGER_VALUE_RANGE }; return ::comphelper::combineSequences( getAggregateServiceNames(), diff --git a/forms/source/component/spinbutton.cxx b/forms/source/component/spinbutton.cxx index 5d12db677be9..c294983c21cb 100644 --- a/forms/source/component/spinbutton.cxx +++ b/forms/source/component/spinbutton.cxx @@ -73,7 +73,7 @@ namespace frm // to benefit from the functionality for binding to spreadsheet cells Sequence< OUString > SAL_CALL OSpinButtonModel::getSupportedServiceNames() { - Sequence< OUString > aOwnNames { FRM_SUN_COMPONENT_SPINBUTTON, BINDABLE_INTEGER_VALUE_RANGE }; + static constexpr OUString aOwnNames[] { FRM_SUN_COMPONENT_SPINBUTTON, BINDABLE_INTEGER_VALUE_RANGE }; return ::comphelper::combineSequences( getAggregateServiceNames(), diff --git a/forms/source/richtext/richtextmodel.cxx b/forms/source/richtext/richtextmodel.cxx index 8ef6d5973b74..fa2900f11903 100644 --- a/forms/source/richtext/richtextmodel.cxx +++ b/forms/source/richtext/richtextmodel.cxx @@ -263,7 +263,7 @@ namespace frm Sequence< OUString > SAL_CALL ORichTextModel::getSupportedServiceNames() { - Sequence< OUString > aOwnNames { + static constexpr OUString aOwnNames[] { FRM_SUN_COMPONENT_RICHTEXTCONTROL, u"com.sun.star.text.TextRange"_ustr, u"com.sun.star.style.CharacterProperties"_ustr, diff --git a/svx/source/form/fmdmod.cxx b/svx/source/form/fmdmod.cxx index 1c5468f49f3c..ea1c80aeaa18 100644 --- a/svx/source/form/fmdmod.cxx +++ b/svx/source/form/fmdmod.cxx @@ -81,12 +81,8 @@ using namespace ::svxform; FM_SUN_COMPONENT_IMAGECONTROL }; - static const sal_uInt16 nSvxComponentServiceNameListCount = SAL_N_ELEMENTS(aSvxComponentServiceNameList); - - auto aSeq( comphelper::arrayToSequence< OUString >(aSvxComponentServiceNameList, nSvxComponentServiceNameListCount) ); - ::com::sun::star::uno::Sequence< OUString > aParentSeq( SvxUnoDrawMSFactory::getAvailableServiceNames() ); - return comphelper::concatSequences( aParentSeq, aSeq ); + return comphelper::concatSequences(aParentSeq, aSvxComponentServiceNameList); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/form/formcontroller.cxx b/svx/source/form/formcontroller.cxx index 287cb4933eaf..25c368852a87 100644 --- a/svx/source/form/formcontroller.cxx +++ b/svx/source/form/formcontroller.cxx @@ -656,7 +656,7 @@ Sequence< OUString> SAL_CALL FormController::getSupportedServiceNames() { // service names which are supported only, but cannot be used to created an // instance at a service factory - Sequence aNonCreatableServiceNames { u"com.sun.star.form.FormControllerDispatcher"_ustr }; + static constexpr OUString aNonCreatableServiceNames[] { u"com.sun.star.form.FormControllerDispatcher"_ustr }; // services which can be used to created an instance at a service factory Sequence< OUString > aCreatableServiceNames( getSupportedServiceNames_Static() ); diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx index 637305c9e6fc..a38b3e46315f 100644 --- a/svx/source/table/cell.cxx +++ b/svx/source/table/cell.cxx @@ -834,7 +834,7 @@ void SAL_CALL Cell::release() noexcept Sequence< Type > SAL_CALL Cell::getTypes( ) { return comphelper::concatSequences( SvxUnoTextBase::getTypes(), - Sequence { + std::initializer_list{ cppu::UnoType::get(), cppu::UnoType::get() }); } diff --git a/svx/source/unodraw/unomod.cxx b/svx/source/unodraw/unomod.cxx index d6b2dac6b2b7..7cfb7e22227b 100644 --- a/svx/source/unodraw/unomod.cxx +++ b/svx/source/unodraw/unomod.cxx @@ -468,7 +468,7 @@ uno::Sequence< OUString > SAL_CALL SvxUnoDrawingModel::getAvailableServiceNames( { const uno::Sequence< OUString > aSNS_ORG( SvxFmMSFactory::getAvailableServiceNames() ); - uno::Sequence< OUString > aSNS{ + static constexpr OUString aSNS[] { u"com.sun.star.drawing.DashTable"_ustr, u"com.sun.star.drawing.GradientTable"_ustr, u"com.sun.star.drawing.HatchTable"_ustr,