Avoid COW overhead using css::uno::Sequence

Desktop / LibreOffice - Mike Kaganski [collabora.com] - 14 October 2021 04:00 UTC

The scenarios are:

1. Calling sequence's begin() and end() in pairs to pass to algorithms (both calls use getArray(), which does the COW checks) 2. In addition to #1, calling end() again when checking result of find algorithms, and/or begin() to calculate result's distance 3. Using non-const sequences in range-based for loops, which internally do #1 4. Assigning sequence to another sequence variable, and then modifying one of them

In many cases, the sequences could be made const, or treated as const for the purposes of the algorithms (using std::as_const, std::cbegin, and std::cend). Where algorithm modifies the sequence, it was changed to only call getArray() once. For that, css::uno::toNonConstRange was introduced, which returns a struct (sublclass of std::pair) with two iterators [begin, end], that are calculated using one call to begin() and one call to getLength().

To handle #4, css::uno::Sequence::swap was introduced, that swaps the internal pointer to uno_Sequence. So when a local Sequence variable should be assigned to another variable, and the latter will be modified further, it's now possible to use swap instead, so the two sequences are kept independent.

The modified places were found by temporarily removing non-const end().

Change-Id: I8fe2787f200eecb70744e8b77fbdf7a49653f628 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123542

8a017d25a62e Avoid COW overhead using css::uno::Sequence
basctl/source/basicide/scriptdocument.cxx | 5 ++-
chart2/qa/extras/chart2import.cxx | 2 +-
chart2/qa/extras/charttest.hxx | 4 +-
chart2/source/controller/dialogs/DialogModel.cxx | 2 +-
chart2/source/controller/main/ObjectHierarchy.cxx | 2 +-
.../model/template/ColumnLineChartTypeTemplate.cxx | 2 +-
chart2/source/tools/DataSeriesHelper.cxx | 2 +-
chart2/source/tools/DataSourceHelper.cxx | 4 +-
chart2/source/tools/DiagramHelper.cxx | 4 +-
chart2/source/tools/InternalDataProvider.cxx | 10 ++---
chart2/source/tools/UncachedDataSequence.cxx | 4 +-
comphelper/qa/unit/base64_test.cxx | 12 +++---
comphelper/source/property/opropertybag.cxx | 21 +++++-----
.../source/property/propertycontainerhelper.cxx | 10 ++---
.../source/commontools/ConnectionWrapper.cxx | 3 +-
connectivity/source/commontools/dbtools2.cxx | 6 +--
connectivity/source/drivers/jdbc/JStatement.cxx | 5 ++-
connectivity/source/drivers/odbc/OStatement.cxx | 5 ++-
connectivity/source/sdbcx/VDescriptor.cxx | 5 ++-
cppuhelper/source/factory.cxx | 2 +-
dbaccess/source/core/dataaccess/ModelImpl.cxx | 2 +-
dbaccess/source/core/dataaccess/connection.cxx | 2 +-
.../source/core/dataaccess/databasedocument.cxx | 5 ++-
dbaccess/source/core/dataaccess/datasource.cxx | 10 +++--
dbaccess/source/ui/browser/unodatbr.cxx | 5 ++-
dbaccess/source/ui/misc/UITools.cxx | 8 ++--
.../source/ui/misc/dbsubcomponentcontroller.cxx | 5 ++-
dbaccess/source/ui/querydesign/querycontroller.cxx | 5 ++-
desktop/source/lib/init.cxx | 4 +-
desktop/source/lib/lokclipboard.cxx | 4 +-
.../source/bibliography/formcontrolcontainer.cxx | 17 ++++----
extensions/source/propctrlr/cellbindinghelper.cxx | 15 ++++----
extensions/source/propctrlr/eformshelper.cxx | 6 +--
extensions/source/propctrlr/eventhandler.cxx | 4 +-
.../source/propctrlr/formcomponenthandler.cxx | 2 +-
.../source/propctrlr/genericpropertyhandler.cxx | 4 +-
.../source/propctrlr/stringrepresentation.cxx | 3 +-
.../source/propctrlr/xsdvalidationhelper.cxx | 9 +++--
forms/source/component/ListBox.cxx | 14 +++----
forms/source/component/propertybaghelper.cxx | 2 +-
forms/source/misc/InterfaceContainer.cxx | 3 +-
framework/qa/cppunit/dispatchtest.cxx | 4 +-
framework/source/services/autorecovery.cxx | 2 +-
i18npool/qa/cppunit/test_ordinalsuffix.cxx | 38 ++++++------------
.../ignoreIandEfollowedByYa_ja_JP.cxx | 3 +-
.../transliteration/ignoreIterationMark_ja_JP.cxx | 3 +-
.../ignoreKiKuFollowedBySa_ja_JP.cxx | 3 +-
.../ignoreProlongedSoundMark_ja_JP.cxx | 3 +-
.../source/transliteration/transliterationImpl.cxx | 34 +++++++---------
.../transliteration/transliteration_OneToOne.cxx | 3 +-
.../transliteration/transliteration_body.cxx | 5 ++-
include/com/sun/star/uno/Sequence.h | 10 +++++
include/com/sun/star/uno/Sequence.hxx | 24 ++++++++++++
include/vcl/FilterConfigItem.hxx | 4 +-
include/xmloff/XMLEventExport.hxx | 2 +-
oox/source/crypto/AgileEngine.cxx | 2 +-
oox/source/export/chartexport.cxx | 4 +-
oox/source/helper/zipstorage.cxx | 3 +-
oox/source/ole/olestorage.cxx | 3 +-
reportdesign/source/core/api/ReportDefinition.cxx | 2 +-
sc/source/core/data/dptabsrc.cxx | 2 +-
sc/source/core/tool/addincol.cxx | 4 +-
sc/source/core/tool/rangeseq.cxx | 2 +-
sc/source/filter/xml/xmlcvali.cxx | 4 +-
sc/source/ui/Accessibility/AccessibleCell.cxx | 5 ++-
sc/source/ui/miscdlgs/optsolver.cxx | 12 +++---
sc/source/ui/unoobj/dapiuno.cxx | 6 +--
sc/source/ui/vba/vbaworkbook.cxx | 5 ++-
scripting/source/basprov/basmethnode.cxx | 2 +-
.../source/provider/BrowseNodeFactoryImpl.cxx | 2 +-
scripting/source/provider/ProviderCache.cxx | 2 +-
scripting/source/provider/URIHelper.cxx | 2 +-
scripting/source/vbaevents/eventhelper.cxx | 2 +-
sd/qa/unit/export-tests-ooxml3.cxx | 4 +-
sd/source/core/CustomAnimationEffect.cxx | 45 +++++++++++++---------
sd/source/core/CustomAnimationPreset.cxx | 2 +-
sd/source/core/TransitionPreset.cxx | 2 +-
sd/source/core/stlsheet.cxx | 2 +-
sd/source/filter/eppt/pptexanimations.cxx | 2 +-
sd/source/filter/html/HtmlOptionsDialog.cxx | 13 ++++---
.../ui/framework/configuration/ResourceId.cxx | 2 +-
sd/source/ui/remotecontrol/Server.cxx | 2 +-
sd/source/ui/view/ViewShellBase.cxx | 4 +-
sdext/source/minimizer/fileopendialog.cxx | 4 +-
sdext/source/presenter/PresenterScreen.cxx | 4 +-
sdext/source/presenter/PresenterTheme.cxx | 2 +-
sfx2/source/appl/appopen.cxx | 8 ++--
sfx2/source/appl/sfxhelp.cxx | 4 +-
sfx2/source/control/charmapcontrol.cxx | 8 ++--
.../source/devtools/ObjectInspectorTreeHandler.cxx | 2 +-
sfx2/source/dialog/filedlghelper.cxx | 2 +-
sfx2/source/dialog/filtergrouping.cxx | 8 ++--
sfx2/source/dialog/mailmodel.cxx | 2 +-
sfx2/source/doc/docfile.cxx | 6 +--
sfx2/source/doc/docinsert.cxx | 2 +-
sfx2/source/doc/guisaveas.cxx | 4 +-
sfx2/source/doc/objmisc.cxx | 2 +-
sfx2/source/doc/objserv.cxx | 2 +-
sfx2/source/doc/objstor.cxx | 12 +++---
sfx2/source/doc/sfxbasemodel.cxx | 16 ++++----
sfx2/source/sidebar/ResourceManager.cxx | 2 +-
starmath/source/mathml/mathmlexport.cxx | 4 +-
stoc/source/implementationregistration/implreg.cxx | 21 +++++-----
stoc/source/inspect/introspection.cxx | 4 +-
stoc/source/invocation/invocation.cxx | 2 +-
stoc/source/servicemanager/servicemanager.cxx | 6 +--
svl/source/config/asiancfg.cxx | 2 +-
svl/source/numbers/zforlist.cxx | 26 ++++++-------
svl/source/numbers/zformat.cxx | 2 +-
svl/source/passwordcontainer/passwordcontainer.cxx | 2 +-
svl/source/passwordcontainer/syscreds.cxx | 2 +-
svtools/source/dialogs/addresstemplate.cxx | 4 +-
svtools/source/filter/SvFilterOptionsDialog.cxx | 9 +++--
svtools/source/uno/unocontroltablemodel.cxx | 2 +-
svx/source/accessibility/AccessibleShape.cxx | 4 +-
svx/source/fmcomp/fmgridcl.cxx | 8 ++--
svx/source/fmcomp/fmgridif.cxx | 2 +-
svx/source/form/fmshimp.cxx | 2 +-
svx/source/form/fmsrcimp.cxx | 2 +-
svx/source/form/fmtextcontrolshell.cxx | 2 +-
svx/source/form/formcontrolfactory.cxx | 2 +-
svx/source/form/formcontroller.cxx | 18 ++++-----
svx/source/items/customshapeitem.cxx | 6 +--
svx/source/table/accessiblecell.cxx | 2 +-
sw/qa/extras/ooxmlexport/ooxmlexport10.cxx | 6 +--
sw/qa/extras/ooxmlexport/ooxmlexport12.cxx | 2 +-
sw/qa/extras/ooxmlexport/ooxmlexport13.cxx | 4 +-
sw/qa/extras/ooxmlexport/ooxmlexport16.cxx | 2 +-
sw/qa/unit/swmodeltestbase.cxx | 4 +-
sw/source/core/access/accselectionhelper.cxx | 2 +-
sw/source/core/edit/edlingu.cxx | 10 ++---
sw/source/core/unocore/unochart.cxx | 9 +++--
sw/source/core/unocore/unocoll.cxx | 2 +-
sw/source/core/unocore/unoframe.cxx | 4 +-
sw/source/core/unocore/unoparagraph.cxx | 2 +-
sw/source/core/unocore/unoport.cxx | 2 +-
sw/source/filter/ww8/docxattributeoutput.cxx | 20 +++++-----
sw/source/filter/ww8/docxexport.cxx | 16 ++++----
sw/source/filter/ww8/docxsdrexport.cxx | 12 +++---
sw/source/filter/ww8/docxtablestyleexport.cxx | 4 +-
sw/source/filter/ww8/wrtww8.cxx | 3 +-
sw/source/ui/dbui/mmaddressblockpage.cxx | 9 +++--
sw/source/ui/envelp/mailmrge.cxx | 4 +-
sw/source/ui/vba/vbadocumentproperties.cxx | 7 ++--
sw/source/ui/vba/vbafilterpropsfromformat.hxx | 10 ++---
sw/source/ui/vba/vbastyles.cxx | 2 +-
sw/source/ui/vba/vbatabstops.cxx | 10 +++--
sw/source/uibase/dbui/dbmgr.cxx | 2 +-
sw/source/uibase/dbui/dbtree.cxx | 3 +-
sw/source/uibase/dbui/mmconfigitem.cxx | 7 ++--
sw/source/uibase/fldui/fldmgr.cxx | 2 +-
sw/source/uibase/misc/numberingtypelistbox.cxx | 3 +-
sw/source/uibase/uno/unotxdoc.cxx | 2 +-
test/source/sheet/xdatapilottable2.cxx | 2 +-
toolkit/source/controls/geometrycontrolmodel.cxx | 15 ++++----
toolkit/source/controls/stdtabcontroller.cxx | 8 ++--
toolkit/source/controls/unocontrol.cxx | 2 +-
toolkit/source/controls/unocontrolcontainer.cxx | 6 +--
toolkit/source/controls/unocontrols.cxx | 28 +++++++-------
toolkit/source/helper/formpdfexport.cxx | 4 +-
ucb/source/cacher/cachedcontentresultset.cxx | 2 +-
ucb/source/core/ucbcmds.cxx | 16 ++++----
ucb/source/core/ucbprops.cxx | 4 +-
ucb/source/ucp/file/filcmd.cxx | 12 +++---
ucb/source/ucp/file/filprp.cxx | 6 +--
ucb/source/ucp/file/filrset.cxx | 6 +--
ucb/source/ucp/file/prov.cxx | 6 +--
ucb/source/ucp/ftp/ftpcontent.cxx | 2 +-
ucb/source/ucp/ftp/ftpresultsetbase.cxx | 6 +--
ucb/source/ucp/webdav-neon/webdavcontent.cxx | 2 +-
ucbhelper/source/provider/providerhelper.cxx | 2 +-
ucbhelper/source/provider/resultsetmetadata.cxx | 2 +-
unotools/source/config/cmdoptions.cxx | 5 +--
unotools/source/config/configitem.cxx | 6 +--
unotools/source/config/confignode.cxx | 2 +-
unotools/source/config/moduleoptions.cxx | 8 ++--
unotools/source/i18n/localedatawrapper.cxx | 4 +-
uui/source/iahndl-filter.cxx | 4 +-
uui/source/iahndl-ssl.cxx | 2 +-
vbahelper/source/msforms/vbalistbox.cxx | 2 +-
vbahelper/source/msforms/vbalistcontrolhelper.cxx | 2 +-
vbahelper/source/vbahelper/vbacommandbarhelper.cxx | 2 +-
vbahelper/source/vbahelper/vbacommandbars.cxx | 2 +-
vbahelper/source/vbahelper/vbahelper.cxx | 5 ++-
vcl/source/filter/FilterConfigItem.cxx | 12 +++---
vcl/source/filter/graphicfilter.cxx | 2 +-
vcl/source/gdi/configsettings.cxx | 12 +++---
vcl/source/graphic/UnoGraphic.cxx | 2 +-
vcl/source/helper/commandinfoprovider.cxx | 4 +-
.../source/dmapper/DomainMapperTableHandler.cxx | 4 +-
.../source/dmapper/DomainMapperTableHandler.hxx | 2 +-
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 12 +++---
writerfilter/source/dmapper/GraphicImport.cxx | 2 +-
writerfilter/source/dmapper/NumberingManager.cxx | 10 ++---
writerfilter/source/dmapper/PropertyMap.cxx | 10 ++---
writerfilter/source/dmapper/StyleSheetTable.cxx | 2 +-
writerperfect/qa/unit/WpftLoader.cxx | 7 ++--
xmlhelp/source/cxxhelp/provider/content.cxx | 4 +-
xmlhelp/source/cxxhelp/provider/databases.cxx | 2 +-
xmlhelp/source/cxxhelp/provider/resultsetbase.cxx | 6 +--
xmlhelp/source/treeview/tvread.cxx | 2 +-
xmloff/source/chart/SchXMLChartContext.cxx | 2 +-
xmloff/source/chart/SchXMLExport.cxx | 23 +++++------
xmloff/source/chart/SchXMLImport.cxx | 2 +-
xmloff/source/chart/SchXMLSeries2Context.cxx | 2 +-
xmloff/source/chart/SchXMLSeriesHelper.cxx | 4 +-
xmloff/source/draw/SignatureLineContext.cxx | 2 +-
xmloff/source/forms/elementimport.cxx | 2 +-
xmloff/source/forms/formcellbinding.cxx | 7 ++--
xmloff/source/script/XMLEventExport.cxx | 2 +-
xmloff/source/style/tabsthdl.cxx | 2 +-
xmloff/source/style/xmlnumfe.cxx | 2 +-
xmloff/source/table/XMLTableExport.cxx | 2 +-
xmloff/source/text/XMLSectionExport.cxx | 4 +-
xmloff/source/text/XMLTextNumRuleInfo.cxx | 4 +-
xmloff/source/text/txtimp.cxx | 4 +-
xmloff/source/text/txtprhdl.cxx | 4 +-
xmlsecurity/qa/unit/signing/signing.cxx | 2 +-
.../source/helper/documentsignaturehelper.cxx | 4 +-
xmlsecurity/source/helper/xmlsignaturehelper.cxx | 4 +-
220 files changed, 653 insertions(+), 603 deletions(-)

Upstream: cgit.freedesktop.org


  • Share