summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@yahoo.com>2014-08-23 14:42:56 +0200
committerMatteo Casalin <matteo.casalin@yahoo.com>2014-09-06 12:09:03 +0200
commitb5bd7e607adc4478bf2d9edb61c90d5b43554294 (patch)
tree1021135ee0486d9035eeed54524567d17c0986d0 /sw
parent0bb1d92c009d940be3b08ed1d1383b93d648eba5 (diff)
Reserve vector capacity in advance + minor optimizations
Change-Id: I04eea6825c02ea0c076b525e58a1dc86dd290b64
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/txtnode/atrftn.cxx9
1 files changed, 7 insertions, 2 deletions
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<sal_uInt16> &rUsedNums,
size_t numRequired)
{
+ if (!numRequired)
+ return;
+
+ rLowestUnusedNums.reserve(numRequired);
sal_uInt16 newNum = 0;
std::set<sal_uInt16>::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 );
}
}