diff options
author | Noel Grandin <noel@peralex.com> | 2016-04-12 16:39:03 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-04-18 07:37:31 +0000 |
commit | 789055bc2acb4c71483fd60ea258d158bd5aec10 (patch) | |
tree | 7849de841a71f667a30b2a971ad0c3d406110396 /dbaccess | |
parent | 150ac9cf05ed9da6a2af5bc3f820280fd853e519 (diff) |
clang-tidy performance-unnecessary-copy-initialization
probably not much performance benefit, but it sure is good at
identifying leftover intermediate variables from previous
refactorings.
Change-Id: I3ce16fe496ac2733c1cb0a35f74c0fc9193cc657
Reviewed-on: https://gerrit.libreoffice.org/24026
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'dbaccess')
-rw-r--r-- | dbaccess/source/core/dataaccess/databasecontext.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/core/misc/dsntypes.cxx | 16 | ||||
-rw-r--r-- | dbaccess/source/core/recovery/subcomponentrecovery.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/app/AppDetailPageHelper.cxx | 3 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/unodatbr.cxx | 7 | ||||
-rw-r--r-- | dbaccess/source/ui/control/SqlNameEdit.cxx | 9 | ||||
-rw-r--r-- | dbaccess/source/ui/dlg/dbwizsetup.cxx | 5 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/UITools.cxx | 7 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/indexcollection.cxx | 16 | ||||
-rw-r--r-- | dbaccess/source/ui/querydesign/QueryDesignView.cxx | 17 | ||||
-rw-r--r-- | dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx | 7 | ||||
-rw-r--r-- | dbaccess/source/ui/querydesign/limitboxcontroller.cxx | 3 | ||||
-rw-r--r-- | dbaccess/source/ui/querydesign/querycontroller.cxx | 3 |
13 files changed, 36 insertions, 61 deletions
diff --git a/dbaccess/source/core/dataaccess/databasecontext.cxx b/dbaccess/source/core/dataaccess/databasecontext.cxx index a82d2273ae07..9c28241fba3d 100644 --- a/dbaccess/source/core/dataaccess/databasecontext.cxx +++ b/dbaccess/source/core/dataaccess/databasecontext.cxx @@ -697,7 +697,7 @@ void ODatabaseContext::registerDatabaseDocument( ODatabaseModelImpl& _rModelImpl void ODatabaseContext::revokeDatabaseDocument( const ODatabaseModelImpl& _rModelImpl ) { - OUString sURL( _rModelImpl.getURL() ); + const OUString& sURL( _rModelImpl.getURL() ); SAL_INFO("dbaccess.core", "DatabaseContext: deregistering " << sURL); m_aDatabaseObjects.erase( sURL ); } diff --git a/dbaccess/source/core/misc/dsntypes.cxx b/dbaccess/source/core/misc/dsntypes.cxx index 54494f171498..a3f8039d8a6f 100644 --- a/dbaccess/source/core/misc/dsntypes.cxx +++ b/dbaccess/source/core/misc/dsntypes.cxx @@ -84,7 +84,6 @@ OUString ODsnTypeCollection::getTypeDisplayName(const OUString& _sURL) const OUString ODsnTypeCollection::cutPrefix(const OUString& _sURL) const { - OUString sURL( _sURL); OUString sRet; OUString sOldPattern; StringVector::const_iterator aIter = m_aDsnPrefixes.begin(); @@ -99,8 +98,8 @@ OUString ODsnTypeCollection::cutPrefix(const OUString& _sURL) const // foo* // that is, the very concept of "prefix" applies. OUString prefix(comphelper::string::stripEnd(*aIter, '*')); - OSL_ENSURE(prefix.getLength() <= sURL.getLength(), "How can A match B when A shorter than B?"); - sRet = sURL.copy(prefix.getLength()); + OSL_ENSURE(prefix.getLength() <= _sURL.getLength(), "How can A match B when A shorter than B?"); + sRet = _sURL.copy(prefix.getLength()); sOldPattern = *aIter; } } @@ -110,7 +109,6 @@ OUString ODsnTypeCollection::cutPrefix(const OUString& _sURL) const OUString ODsnTypeCollection::getPrefix(const OUString& _sURL) const { - OUString sURL( _sURL); OUString sRet; OUString sOldPattern; StringVector::const_iterator aIter = m_aDsnPrefixes.begin(); @@ -118,13 +116,13 @@ OUString ODsnTypeCollection::getPrefix(const OUString& _sURL) const for(;aIter != aEnd;++aIter) { WildCard aWildCard(*aIter); - if ( sOldPattern.getLength() < aIter->getLength() && aWildCard.Matches(sURL) ) + if ( sOldPattern.getLength() < aIter->getLength() && aWildCard.Matches(_sURL) ) { // This relies on the fact that all patterns are of the form // foo* // that is, the very concept of "prefix" applies. sRet = comphelper::string::stripEnd(*aIter, '*'); - OSL_ENSURE(sRet.getLength() <= sURL.getLength(), "How can A match B when A shorter than B?"); + OSL_ENSURE(sRet.getLength() <= _sURL.getLength(), "How can A match B when A shorter than B?"); sOldPattern = *aIter; } } @@ -140,7 +138,6 @@ bool ODsnTypeCollection::hasDriver( const sal_Char* _pAsciiPattern ) const bool ODsnTypeCollection::isConnectionUrlRequired(const OUString& _sURL) const { - OUString sURL( _sURL); OUString sRet; OUString sOldPattern; StringVector::const_iterator aIter = m_aDsnPrefixes.begin(); @@ -148,7 +145,7 @@ bool ODsnTypeCollection::isConnectionUrlRequired(const OUString& _sURL) const for(;aIter != aEnd;++aIter) { WildCard aWildCard(*aIter); - if ( sOldPattern.getLength() < aIter->getLength() && aWildCard.Matches(sURL) ) + if ( sOldPattern.getLength() < aIter->getLength() && aWildCard.Matches(_sURL) ) { sRet = *aIter; sOldPattern = *aIter; @@ -507,14 +504,13 @@ OUString ODsnTypeCollection::getType(const OUString& _sURL) const sal_Int32 ODsnTypeCollection::getIndexOf(const OUString& _sURL) const { sal_Int32 nRet = -1; - OUString sURL( _sURL); OUString sOldPattern; StringVector::const_iterator aIter = m_aDsnPrefixes.begin(); StringVector::const_iterator aEnd = m_aDsnPrefixes.end(); for(sal_Int32 i = 0;aIter != aEnd;++aIter,++i) { WildCard aWildCard(*aIter); - if ( sOldPattern.getLength() < aIter->getLength() && aWildCard.Matches(sURL) ) + if ( sOldPattern.getLength() < aIter->getLength() && aWildCard.Matches(_sURL) ) { nRet = i; sOldPattern = *aIter; diff --git a/dbaccess/source/core/recovery/subcomponentrecovery.cxx b/dbaccess/source/core/recovery/subcomponentrecovery.cxx index 00439934be32..d36b11ef6e1d 100644 --- a/dbaccess/source/core/recovery/subcomponentrecovery.cxx +++ b/dbaccess/source/core/recovery/subcomponentrecovery.cxx @@ -562,7 +562,7 @@ namespace dbaccess aDesignInput.import( pDocHandler.get() ); const ::comphelper::NamedValueCollection& rSettings( pDocHandler->getSettings() ); - const Any aCurrentQueryDesign = rSettings.get( sCurrentQueryDesignName ); + const Any& aCurrentQueryDesign = rSettings.get( sCurrentQueryDesignName ); #if OSL_DEBUG_LEVEL > 0 Sequence< PropertyValue > aQueryDesignLayout; OSL_VERIFY( aCurrentQueryDesign >>= aQueryDesignLayout ); diff --git a/dbaccess/source/ui/app/AppDetailPageHelper.cxx b/dbaccess/source/ui/app/AppDetailPageHelper.cxx index 29dffc9ba562..822ca0ce7bec 100644 --- a/dbaccess/source/ui/app/AppDetailPageHelper.cxx +++ b/dbaccess/source/ui/app/AppDetailPageHelper.cxx @@ -786,7 +786,6 @@ void OAppDetailPageHelper::elementReplaced(ElementType _eType DBTreeListBox* pTreeView = getCurrentView(); if ( pTreeView ) { - OUString sNewName = _rNewName; SvTreeListEntry* pEntry = nullptr; switch( _eType ) { @@ -808,7 +807,7 @@ void OAppDetailPageHelper::elementReplaced(ElementType _eType OSL_ENSURE(pEntry,"Do you know that the name isn't existence!"); if ( pEntry ) { - pTreeView->SetEntryText(pEntry,sNewName); + pTreeView->SetEntryText(pEntry,_rNewName); } } } diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx index 1f04843d3ee6..297dd921eecd 100644 --- a/dbaccess/source/ui/browser/unodatbr.cxx +++ b/dbaccess/source/ui/browser/unodatbr.cxx @@ -1190,7 +1190,6 @@ SvTreeListEntry* SbaTableQueryBrowser::getObjectEntry(const OUString& _rDataSour } // look for the object - OUString sCommand = _rCommand; sal_Int32 nIndex = 0; do { @@ -1198,7 +1197,7 @@ SvTreeListEntry* SbaTableQueryBrowser::getObjectEntry(const OUString& _rDataSour switch (_nCommandType) { case CommandType::TABLE: - sPath = sCommand; + sPath = _rCommand; nIndex = -1; break; @@ -1206,7 +1205,7 @@ SvTreeListEntry* SbaTableQueryBrowser::getObjectEntry(const OUString& _rDataSour assert(false); // in non-debug builds, fall through. case CommandType::QUERY: - sPath = sCommand.getToken( 0, '/', nIndex ); + sPath = _rCommand.getToken( 0, '/', nIndex ); break; } pObject = m_pTreeView->getListBox().GetEntryPosByName(sPath, pCommandType); @@ -1218,7 +1217,7 @@ SvTreeListEntry* SbaTableQueryBrowser::getObjectEntry(const OUString& _rDataSour DBTreeListUserData* pParentData = static_cast< DBTreeListUserData* >( pObject->GetUserData() ); Reference< XNameAccess > xCollection( pParentData->xContainer, UNO_QUERY ); sal_Int32 nIndex2 = nIndex; - sPath = sCommand.getToken( 0, '/', nIndex2 ); + sPath = _rCommand.getToken( 0, '/', nIndex2 ); try { if ( xCollection->hasByName(sPath) ) diff --git a/dbaccess/source/ui/control/SqlNameEdit.cxx b/dbaccess/source/ui/control/SqlNameEdit.cxx index 2816c9866241..5c025afd9655 100644 --- a/dbaccess/source/ui/control/SqlNameEdit.cxx +++ b/dbaccess/source/ui/control/SqlNameEdit.cxx @@ -38,18 +38,17 @@ namespace dbaui bool bCorrected = false; if ( m_bCheck ) { - OUString sText = _sToCheck; sal_Int32 nMatch = 0; - for (sal_Int32 i = nMatch; i < sText.getLength(); ++i) + for (sal_Int32 i = nMatch; i < _sToCheck.getLength(); ++i) { - if ( !isCharOk( sText[i], i == 0, m_bOnlyUpperCase, m_sAllowedChars ) ) + if ( !isCharOk( _sToCheck[i], i == 0, m_bOnlyUpperCase, m_sAllowedChars ) ) { - _rsCorrected += sText.copy(nMatch, i - nMatch); + _rsCorrected += _sToCheck.copy(nMatch, i - nMatch); bCorrected = true; nMatch = i + 1; } } - _rsCorrected += sText.copy( nMatch, sText.getLength() - nMatch ); + _rsCorrected += _sToCheck.copy( nMatch, _sToCheck.getLength() - nMatch ); } return bCorrected; } diff --git a/dbaccess/source/ui/dlg/dbwizsetup.cxx b/dbaccess/source/ui/dlg/dbwizsetup.cxx index 81e6e0660a87..520d962d1d6f 100644 --- a/dbaccess/source/ui/dlg/dbwizsetup.cxx +++ b/dbaccess/source/ui/dlg/dbwizsetup.cxx @@ -755,7 +755,7 @@ bool ODbTypeWizDialogSetup::SaveDatabaseDocument() void ODbTypeWizDialogSetup::CreateDatabase() { OUString sUrl; - OUString eType = m_pGeneralPage->GetSelectedType(); + const OUString eType = m_pGeneralPage->GetSelectedType(); if ( dbaccess::ODsnTypeCollection::isEmbeddedDatabase(eType) ) { sUrl = eType; @@ -771,10 +771,9 @@ bool ODbTypeWizDialogSetup::SaveDatabaseDocument() INetURLObject aDBPathURL(m_sWorkPath); aDBPathURL.Append(m_aDocURL.getBase()); createUniqueFolderName(&aDBPathURL); - OUString sPrefix = eType; sUrl = aDBPathURL.GetMainURL( INetURLObject::NO_DECODE); xSimpleFileAccess->createFolder(sUrl); - sUrl = sPrefix.concat(sUrl); + sUrl = eType.concat(sUrl); } m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, sUrl)); m_pImpl->saveChanges(*m_pOutSet); diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx index c618a1bcae50..c178dfb22a81 100644 --- a/dbaccess/source/ui/misc/UITools.cxx +++ b/dbaccess/source/ui/misc/UITools.cxx @@ -1397,10 +1397,9 @@ bool insertHierachyElement( vcl::Window* _pParent, const Reference< XComponentCo return false; Reference<XNameAccess> xNameAccess( _xNames, UNO_QUERY ); - OUString sName = _sParentFolder; - if ( _xNames->hasByHierarchicalName(sName) ) + if ( _xNames->hasByHierarchicalName(_sParentFolder) ) { - Reference<XChild> xChild(_xNames->getByHierarchicalName(sName),UNO_QUERY); + Reference<XChild> xChild(_xNames->getByHierarchicalName(_sParentFolder),UNO_QUERY); xNameAccess.set(xChild,UNO_QUERY); if ( !xNameAccess.is() && xChild.is() ) xNameAccess.set(xChild->getParent(),UNO_QUERY); @@ -1428,7 +1427,7 @@ bool insertHierachyElement( vcl::Window* _pParent, const Reference< XComponentCo sTargetName = ::dbtools::createUniqueName(xNameAccess,sTargetName); // here we have everything needed to create a new query object ... - HierarchicalNameCheck aNameChecker( _xNames.get(), sName ); + HierarchicalNameCheck aNameChecker( _xNames.get(), _sParentFolder ); // ... ehm, except a new name ScopedVclPtrInstance<OSaveAsDlg> aAskForName( _pParent, diff --git a/dbaccess/source/ui/misc/indexcollection.cxx b/dbaccess/source/ui/misc/indexcollection.cxx index 94790d3a7efe..971a25fe0f29 100644 --- a/dbaccess/source/ui/misc/indexcollection.cxx +++ b/dbaccess/source/ui/misc/indexcollection.cxx @@ -67,13 +67,11 @@ namespace dbaui Indexes::const_iterator OIndexCollection::find(const OUString& _rName) const { - OUString sNameCompare(_rName); - // loop'n'compare Indexes::const_iterator aSearch = m_aIndexes.begin(); Indexes::const_iterator aEnd = m_aIndexes.end(); for (; aSearch != aEnd; ++aSearch) - if (aSearch->sName == sNameCompare) + if (aSearch->sName == _rName) break; return aSearch; @@ -81,13 +79,11 @@ namespace dbaui Indexes::iterator OIndexCollection::find(const OUString& _rName) { - OUString sNameCompare(_rName); - // loop'n'compare Indexes::iterator aSearch = m_aIndexes.begin(); Indexes::const_iterator aEnd = m_aIndexes.end(); for (; aSearch != aEnd; ++aSearch) - if (aSearch->sName == sNameCompare) + if (aSearch->sName == _rName) break; return aSearch; @@ -95,13 +91,11 @@ namespace dbaui Indexes::const_iterator OIndexCollection::findOriginal(const OUString& _rName) const { - OUString sNameCompare(_rName); - // loop'n'compare Indexes::const_iterator aSearch = m_aIndexes.begin(); Indexes::const_iterator aEnd = m_aIndexes.end(); for (; aSearch != aEnd; ++aSearch) - if (aSearch->getOriginalName() == sNameCompare) + if (aSearch->getOriginalName() == _rName) break; return aSearch; @@ -109,13 +103,11 @@ namespace dbaui Indexes::iterator OIndexCollection::findOriginal(const OUString& _rName) { - OUString sNameCompare(_rName); - // loop'n'compare Indexes::iterator aSearch = m_aIndexes.begin(); Indexes::const_iterator aEnd = m_aIndexes.end(); for (; aSearch != aEnd; ++aSearch) - if (aSearch->getOriginalName() == sNameCompare) + if (aSearch->getOriginalName() == _rName) break; return aSearch; diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx index 8d88ec3408f7..6d303db5b019 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx +++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx @@ -788,10 +788,9 @@ namespace else aHavingStr += aWork; - OUString aTmp = aCriteria; OUString aErrorMsg; Reference<XPropertySet> xColumn; - std::unique_ptr< ::connectivity::OSQLParseNode> pParseNode(_pView->getPredicateTreeFromEntry(pEntryField,aTmp,aErrorMsg,xColumn)); + std::unique_ptr< ::connectivity::OSQLParseNode> pParseNode(_pView->getPredicateTreeFromEntry(pEntryField,aCriteria,aErrorMsg,xColumn)); if (pParseNode.get()) { if (bMulti && !(pEntryField->isOtherFunction() || (aFieldName.toChar() == '*'))) @@ -819,10 +818,9 @@ namespace aWhereStr += " "; // aCriteria could have some german numbers so I have to be sure here - OUString aTmp = aCriteria; OUString aErrorMsg; Reference<XPropertySet> xColumn; - std::unique_ptr< ::connectivity::OSQLParseNode> pParseNode( _pView->getPredicateTreeFromEntry(pEntryField,aTmp,aErrorMsg,xColumn)); + std::unique_ptr< ::connectivity::OSQLParseNode> pParseNode( _pView->getPredicateTreeFromEntry(pEntryField,aCriteria,aErrorMsg,xColumn)); if (pParseNode.get()) { if (bMulti && !(pEntryField->isOtherFunction() || (aFieldName.toChar() == '*'))) @@ -888,7 +886,7 @@ namespace OUString& _rsRet) { const OQueryController& rController = static_cast<OQueryController&>(_pView->getController()); - Reference< XConnection> xConnection = rController.getConnection(); + const Reference< XConnection>& xConnection = rController.getConnection(); if ( !xConnection.is() ) return eNoConnection; @@ -964,8 +962,7 @@ namespace if ( !aWorkStr.isEmpty() ) { const sal_Int32 nMaxOrder = xMetaData->getMaxColumnsInOrderBy(); - OUString sToken(aWorkStr); - if ( nMaxOrder && nMaxOrder < comphelper::string::getTokenCount(sToken, ',') ) + if ( nMaxOrder && nMaxOrder < comphelper::string::getTokenCount(aWorkStr, ',') ) eErrorCode = eStatementTooLong; else { @@ -2239,8 +2236,7 @@ namespace if ( SQL_ISRULE(pColumnRef,general_set_fct) ) { aInfo->SetFunctionType(nFunctionType|FKT_AGGREGATE); - OUString aCol(aColumns); - aInfo->SetFunction(comphelper::string::stripEnd(aCol.getToken(0,'('), ' ')); + aInfo->SetFunction(comphelper::string::stripEnd(aColumns.getToken(0,'('), ' ')); } else aInfo->SetFunctionType(nFunctionType|FKT_OTHER); @@ -3081,7 +3077,6 @@ OSQLParseNode* OQueryDesignView::getPredicateTreeFromEntry(const OTableFieldDesc } } - OUString sTest(_sCriteria); // _rxColumn, if it is a "lookup" column, not a computed column, // is guaranteed to be the column taken from the *source* of the column, // that is either a table or another query. @@ -3095,7 +3090,7 @@ OSQLParseNode* OQueryDesignView::getPredicateTreeFromEntry(const OTableFieldDesc // We are currently treating the entry "C='foo'" // Then _rxColumn has Name "C" and RealName "cee". We should *obviously* use "C", not "cee". OSQLParseNode* pParseNode = rParser.predicateTree( _rsErrorMessage, - sTest, + _sCriteria, static_cast<OQueryController&>(getController()).getNumberFormatter(), _rxColumn, false); diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx index a35cdc43727f..ae0e953233de 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx @@ -66,10 +66,9 @@ namespace bool bAsterisk = !(!_sFieldName.isEmpty() && _sFieldName.toChar() != '*'); if ( !bAsterisk ) { - OUString sName = _sFieldName; - sal_Int32 nTokenCount = comphelper::string::getTokenCount(sName, '.'); - if ( (nTokenCount == 2 && sName.getToken(1,'.')[0] == '*' ) - || (nTokenCount == 3 && sName.getToken(2,'.')[0] == '*' ) ) + sal_Int32 nTokenCount = comphelper::string::getTokenCount(_sFieldName, '.'); + if ( (nTokenCount == 2 && _sFieldName.getToken(1,'.')[0] == '*' ) + || (nTokenCount == 3 && _sFieldName.getToken(2,'.')[0] == '*' ) ) { bAsterisk = true; } diff --git a/dbaccess/source/ui/querydesign/limitboxcontroller.cxx b/dbaccess/source/ui/querydesign/limitboxcontroller.cxx index 46c6154ceb6c..19b60e6f13e2 100644 --- a/dbaccess/source/ui/querydesign/limitboxcontroller.cxx +++ b/dbaccess/source/ui/querydesign/limitboxcontroller.cxx @@ -190,11 +190,10 @@ throw (uno::RuntimeException, std::exception) } uno::Reference< awt::XWindow > SAL_CALL LimitBoxController::createItemWindow( - const uno::Reference< awt::XWindow >& Parent ) + const uno::Reference< awt::XWindow >& xParent ) throw (uno::RuntimeException, std::exception) { uno::Reference< awt::XWindow > xItemWindow; - uno::Reference< awt::XWindow > xParent( Parent ); vcl::Window* pParent = VCLUnoHelper::GetWindow( xParent ); if ( pParent ) diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx index a0f844c9b891..3db08021bf1e 100644 --- a/dbaccess/source/ui/querydesign/querycontroller.cxx +++ b/dbaccess/source/ui/querydesign/querycontroller.cxx @@ -1756,8 +1756,7 @@ OUString OQueryController::translateStatement( bool _bFireStatementChange ) { ModuleRes aModuleRes(STR_QRY_NOSELECT); OUString sTmpStr(aModuleRes); - OUString sError(sTmpStr); - showError(SQLException(sError,nullptr,"S1000",1000,Any())); + showError(SQLException(sTmpStr,nullptr,"S1000",1000,Any())); } else sTranslatedStmt = m_sStatement; |