diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-10-14 14:57:54 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-10-14 21:28:40 +0200 |
commit | 1f9468fc29874eae5100317282ab8b395904406d (patch) | |
tree | 7da605653b3a979d18c2283f42ac8a3efd9eae63 /sc | |
parent | 43b0d4f709a3a1446a32e36abb5deaa3bb45ddd9 (diff) |
use std::vector::insert instead of push_back
because it will pre-allocate space and often is optimised to memcpy
Change-Id: I03ed7915f2762d3d27e378638052a47a28bbf096
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123588
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/rangelst.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/column3.cxx | 10 | ||||
-rw-r--r-- | sc/source/core/data/documen5.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/data/dpdimsave.cxx | 4 | ||||
-rw-r--r-- | sc/source/filter/oox/sheetdatabuffer.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/unoobj/cellsuno.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/view/drawvie4.cxx | 3 |
7 files changed, 10 insertions, 19 deletions
diff --git a/sc/inc/rangelst.hxx b/sc/inc/rangelst.hxx index f35e4459c6ec..5489ab44b1b9 100644 --- a/sc/inc/rangelst.hxx +++ b/sc/inc/rangelst.hxx @@ -98,6 +98,8 @@ public: ::std::vector<ScRange>::const_iterator end() const { return maRanges.end(); } ::std::vector<ScRange>::iterator begin() { return maRanges.begin(); } ::std::vector<ScRange>::iterator end() { return maRanges.end(); } + void insert(std::vector<ScRange>::iterator aPos, std::vector<ScRange>::const_iterator aSourceBegin, std::vector<ScRange>::const_iterator aSourceEnd) + { maRanges.insert(aPos, aSourceBegin, aSourceEnd); } void swap( ScRangeList& r ); diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index 79f001c12c91..9bbd9c1bca77 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -852,13 +852,9 @@ public: if (!mbFormula) return; - sc::formula_block::iterator it = sc::formula_block::begin(*node.data); - std::advance(it, nOffset); - sc::formula_block::iterator itEnd = it; - std::advance(itEnd, nDataSize); - - for (; it != itEnd; ++it) - maFormulaCells.push_back(*it); + sc::formula_block::iterator it = sc::formula_block::begin(*node.data) + nOffset; + sc::formula_block::iterator itEnd = it + nDataSize; + maFormulaCells.insert(maFormulaCells.end(), it, itEnd); } break; case sc::element_type_empty: diff --git a/sc/source/core/data/documen5.cxx b/sc/source/core/data/documen5.cxx index 68bb7b4a7444..045f67f91424 100644 --- a/sc/source/core/data/documen5.cxx +++ b/sc/source/core/data/documen5.cxx @@ -286,9 +286,7 @@ void ScDocument::UpdateChartArea( const OUString& rChartName, aNewRanges = new ScRangeList; aNewRanges->Parse( aRangesStr, *this, GetAddressConvention()); - - for ( size_t nAdd = 0, nAddCount = rNewList->size(); nAdd < nAddCount; ++nAdd ) - aNewRanges->push_back( (*rNewList)[nAdd] ); + aNewRanges->insert( aNewRanges->begin(), rNewList->begin(), rNewList->end() ); } else { diff --git a/sc/source/core/data/dpdimsave.cxx b/sc/source/core/data/dpdimsave.cxx index ccd940183ca7..c8ac79cc02ad 100644 --- a/sc/source/core/data/dpdimsave.cxx +++ b/sc/source/core/data/dpdimsave.cxx @@ -50,9 +50,7 @@ void ScDPSaveGroupItem::AddElement( const OUString& rName ) void ScDPSaveGroupItem::AddElementsFromGroup( const ScDPSaveGroupItem& rGroup ) { // add all elements of the other group (used for nested grouping) - - for ( const auto& rElement : rGroup.aElements ) - aElements.push_back( rElement ); + aElements.insert( aElements.end(), rGroup.aElements.begin(), rGroup.aElements.end() ); } bool ScDPSaveGroupItem::RemoveElement( const OUString& rName ) diff --git a/sc/source/filter/oox/sheetdatabuffer.cxx b/sc/source/filter/oox/sheetdatabuffer.cxx index e846d15a5b4c..4421c3222a17 100644 --- a/sc/source/filter/oox/sheetdatabuffer.cxx +++ b/sc/source/filter/oox/sheetdatabuffer.cxx @@ -339,8 +339,7 @@ static void addIfNotInMyMap( const StylesBuffer& rStyles, std::map< FormatKeyPai { // add ranges from the rangelist to the existing rangelist for the // matching style ( should we check if they overlap ? ) - for (size_t i = 0, nSize = rRangeList.size(); i < nSize; ++i) - it->second.push_back(rRangeList[i]); + it->second.insert(it->second.end(), rRangeList.begin(), rRangeList.end()); return; } rMap[ FormatKeyPair( nXfId, nFormatId ) ] = rRangeList; diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 73f167b6e57e..30b41197dc55 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -9145,8 +9145,7 @@ const ScRangeList& ScUniqueFormatsEntry::GetRanges() // fill and return ScRangeList aReturnRanges = new ScRangeList; - for ( const auto& rCompletedRange : aCompletedRanges ) - aReturnRanges->push_back( rCompletedRange ); + aReturnRanges->insert( aReturnRanges->end(), aCompletedRanges.begin(), aCompletedRanges.end() ); aCompletedRanges.clear(); return *aReturnRanges; diff --git a/sc/source/ui/view/drawvie4.cxx b/sc/source/ui/view/drawvie4.cxx index cd1851d81082..2887f26811cd 100644 --- a/sc/source/ui/view/drawvie4.cxx +++ b/sc/source/ui/view/drawvie4.cxx @@ -250,8 +250,7 @@ void getOleSourceRanges(const SdrMarkList& rMarkList, bool& rAnyOle, bool& rOneO ScAddress aAddr; if (aRange.Parse(rRangeRep, *pDoc, pDoc->GetAddressConvention()) & ScRefFlags::VALID) { - for(size_t i = 0; i < aRange.size(); ++i) - pRanges->push_back(aRange[i]); + pRanges->insert(pRanges->end(), aRange.begin(), aRange.end()); } else if (aAddr.Parse(rRangeRep, *pDoc, pDoc->GetAddressConvention()) & ScRefFlags::VALID) pRanges->push_back(aAddr); |