diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2018-06-24 11:59:51 +0900 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-24 08:08:07 +0200 |
commit | b42c316fcf36f478c4d4685c5d2294e079310693 (patch) | |
tree | 17c7ddd57531a486aca5ce48e4b69b0f961859d8 /sd | |
parent | 5211bc416e410ead0827912c12d666643e3eb11e (diff) |
sd: Reduce the number of possible intermediate allocations
... by reserving enough space at once.
As the length of these vectors depends/grows on user's input,
this change can be a micro optimization.
Change-Id: I1baa7d1433875491e86403d727f11f676d29a833
Reviewed-on: https://gerrit.libreoffice.org/56346
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/ui/animations/CustomAnimationPane.cxx | 4 | ||||
-rw-r--r-- | sd/source/ui/view/viewshel.cxx | 7 |
2 files changed, 5 insertions, 6 deletions
diff --git a/sd/source/ui/animations/CustomAnimationPane.cxx b/sd/source/ui/animations/CustomAnimationPane.cxx index 44987fcaa791..2421d51ec461 100644 --- a/sd/source/ui/animations/CustomAnimationPane.cxx +++ b/sd/source/ui/animations/CustomAnimationPane.cxx @@ -1778,8 +1778,8 @@ void CustomAnimationPane::onAdd() maViewSelection >>= xShapes; sal_Int32 nCount = xShapes->getCount(); - sal_Int32 nIndex; - for( nIndex = 0; nIndex < nCount; nIndex++ ) + aTargets.reserve( nCount ); + for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ ) { Any aTarget( xShapes->getByIndex( nIndex ) ); aTargets.push_back( aTarget ); diff --git a/sd/source/ui/view/viewshel.cxx b/sd/source/ui/view/viewshel.cxx index be1c561a096a..93f3fcc85684 100644 --- a/sd/source/ui/view/viewshel.cxx +++ b/sd/source/ui/view/viewshel.cxx @@ -1168,7 +1168,7 @@ void ViewShell::ImpGetUndoStrings(SfxItemSet &rSet) const { // prepare list std::vector<OUString> aStringList; - + aStringList.reserve(nCount); for (sal_uInt16 a = 0; a < nCount; ++a) { // generate one String in list per undo step @@ -1195,9 +1195,8 @@ void ViewShell::ImpGetRedoStrings(SfxItemSet &rSet) const { // prepare list ::std::vector< OUString > aStringList; - sal_uInt16 a; - - for( a = 0; a < nCount; a++) + aStringList.reserve(nCount); + for(sal_uInt16 a = 0; a < nCount; a++) // generate one String in list per undo step aStringList.push_back( pUndoManager->GetRedoActionComment(a) ); |