From b5bd7e607adc4478bf2d9edb61c90d5b43554294 Mon Sep 17 00:00:00 2001 From: Matteo Casalin Date: Sat, 23 Aug 2014 14:42:56 +0200 Subject: Reserve vector capacity in advance + minor optimizations Change-Id: I04eea6825c02ea0c076b525e58a1dc86dd290b64 --- sw/source/core/txtnode/atrftn.cxx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'sw') diff --git a/sw/source/core/txtnode/atrftn.cxx b/sw/source/core/txtnode/atrftn.cxx index 47cd29b6b010..e4dcdc6b6c6e 100644 --- a/sw/source/core/txtnode/atrftn.cxx +++ b/sw/source/core/txtnode/atrftn.cxx @@ -90,6 +90,10 @@ namespace { const std::set &rUsedNums, size_t numRequired) { + if (!numRequired) + return; + + rLowestUnusedNums.reserve(numRequired); sal_uInt16 newNum = 0; std::set::iterator it; //Start by using numbers from gaps in rUsedNums @@ -98,16 +102,17 @@ namespace { while ( newNum < *it ) { rLowestUnusedNums.push_back( newNum++ ); - if ( rLowestUnusedNums.size() >= numRequired ) + if ( --numRequired == 0) return; } newNum++; } //Filled in all gaps. Fill the rest of the list with new numbers. - while ( rLowestUnusedNums.size() < numRequired ) + do { rLowestUnusedNums.push_back( newNum++ ); } + while ( --numRequired > 0 ); } } -- cgit