diff options
author | Matteo Casalin <matteo.casalin@yahoo.com> | 2014-08-23 17:32:47 +0200 |
---|---|---|
committer | Matteo Casalin <matteo.casalin@yahoo.com> | 2014-09-06 12:09:04 +0200 |
commit | 80a8509b896b370a34799f36a1ee65e7b8af7291 (patch) | |
tree | ee9661f1684a447f2f034c11713e3886a289d393 /sw | |
parent | b5bd7e607adc4478bf2d9edb61c90d5b43554294 (diff) |
Reserve vector capacity in advance and avoid copying it
Change-Id: I98d1d6fdf6c4646486a751c34e79bddf771b83a9
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/tox/tox.cxx | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/sw/source/core/tox/tox.cxx b/sw/source/core/tox/tox.cxx index ee68b8dce40a..757e5573ec60 100644 --- a/sw/source/core/tox/tox.cxx +++ b/sw/source/core/tox/tox.cxx @@ -93,10 +93,8 @@ const PatternIni aPatternIni[] = {USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX} }; -static SwFormTokens lcl_GetAuthPattern(sal_uInt16 nTypeId) +static void lcl_FillAuthPattern(SwFormTokens &rAuthTokens, sal_uInt16 nTypeId) { - SwFormTokens aRet; - PatternIni aIni = aPatternIni[nTypeId]; sal_uInt16 nVals[5]; nVals[0] = aIni.n1; @@ -105,12 +103,14 @@ static SwFormTokens lcl_GetAuthPattern(sal_uInt16 nTypeId) nVals[3] = aIni.n4; nVals[4] = aIni.n5; + rAuthTokens.reserve(9); // Worst case: Start+Sep1+Auth+3*(Sep2+Auth) + SwFormToken aStartToken( TOKEN_AUTHORITY ); aStartToken.nAuthorityField = AUTH_FIELD_IDENTIFIER; - aRet.push_back( aStartToken ); + rAuthTokens.push_back( aStartToken ); SwFormToken aSeparatorToken( TOKEN_TEXT ); aSeparatorToken.sText = ": "; - aRet.push_back( aSeparatorToken ); + rAuthTokens.push_back( aSeparatorToken ); SwFormToken aTextToken( TOKEN_TEXT ); aTextToken.sText = ", "; @@ -119,17 +119,15 @@ static SwFormTokens lcl_GetAuthPattern(sal_uInt16 nTypeId) if(nVals[i] == USHRT_MAX) break; if( i > 0 ) - aRet.push_back( aTextToken ); + rAuthTokens.push_back( aTextToken ); // -> #i21237# SwFormToken aToken(TOKEN_AUTHORITY); aToken.nAuthorityField = nVals[i]; - aRet.push_back(aToken); + rAuthTokens.push_back(aToken); // <- #i21237# } - - return aRet; } } @@ -345,7 +343,11 @@ SwForm::SwForm( TOXTypes eTyp ) // #i21237# for( sal_uInt16 i = 1; i < GetFormMax(); ++i, ++nPoolId ) // Number 0 is the title { if(TOX_AUTHORITIES == eType) - SetPattern(i, lcl_GetAuthPattern(i)); + { + SwFormTokens aAuthTokens; + lcl_FillAuthPattern(aAuthTokens, i); + SetPattern(i, aAuthTokens); + } else SetPattern( i, aTokens ); |