diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-10-13 08:47:47 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-10-14 08:26:14 +0200 |
commit | 9b5dad13b56bdde7c40970351af3da3a2c3c9350 (patch) | |
tree | abfd4b02743a0e6a93c51c026f4c53f0e21100bc /sc | |
parent | fa71320329999c968feb16ff65be328b5b8ff5e4 (diff) |
loplugin:stringadd look for unnecessary temporaries
which defeat the *StringConcat optimisation.
Also make StringConcat conversions treat a nullptr as an empty string,
to match the O*String(char*) constructors.
Change-Id: If45f5b4b6a535c97bfeeacd9ec472a7603a52e5b
Reviewed-on: https://gerrit.libreoffice.org/80724
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/helper/shared_test_impl.hxx | 2 | ||||
-rw-r--r-- | sc/qa/unit/subsequent_export-test.cxx | 6 | ||||
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 2 | ||||
-rw-r--r-- | sc/qa/unit/ucalc_formula.cxx | 6 | ||||
-rw-r--r-- | sc/source/filter/ftools/ftools.cxx | 8 | ||||
-rw-r--r-- | sc/source/filter/html/htmlexp.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/lotus/lotform.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/dbgui/scuiasciiopt.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/acredlin.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/navipi/content.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/view/tabview5.cxx | 2 |
11 files changed, 20 insertions, 20 deletions
diff --git a/sc/qa/unit/helper/shared_test_impl.hxx b/sc/qa/unit/helper/shared_test_impl.hxx index 88548cca3699..e75a521f0fce 100644 --- a/sc/qa/unit/helper/shared_test_impl.hxx +++ b/sc/qa/unit/helper/shared_test_impl.hxx @@ -283,7 +283,7 @@ void testCeilingFloor_Impl( ScDocument& rDoc ) ScAddress aPos; aPos.Parse(aRef); ASSERT_FORMULA_EQUAL(rDoc, aPos, "AND(K3:K81)", "Wrong formula."); - CPPUNIT_ASSERT_MESSAGE( OString( OString(pORef) + " result is error.").getStr(), + CPPUNIT_ASSERT_MESSAGE( OString( pORef + OStringLiteral(" result is error.")).getStr(), isFormulaWithoutError( rDoc, aPos)); CPPUNIT_ASSERT_EQUAL(1.0, rDoc.GetValue(aPos)); } diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index 4c53441de68a..6711b3aecabb 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -3174,7 +3174,7 @@ void ScExportTest::testSwappedOutImageExport() // Check whether the export code swaps in the image which was swapped out before. ScDocShellRef xDocSh = loadDoc("document_with_two_images.", FORMAT_ODS); - const OString sFailedMessage = OString("Failed on filter: ") + aFilterNames[nFilter]; + const OString sFailedMessage = OStringLiteral("Failed on filter: ") + aFilterNames[nFilter]; CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xDocSh.is()); // Export the document and import again for a check @@ -3288,7 +3288,7 @@ void ScExportTest::testLinkedGraphicRT() { // Load the original file with one image ScDocShellRef xDocSh = loadDoc("document_with_linked_graphic.", FORMAT_ODS); - const OString sFailedMessage = OString("Failed on filter: ") + aFilterNames[nFilter]; + const OString sFailedMessage = OStringLiteral("Failed on filter: ") + aFilterNames[nFilter]; // Export the document and import again for a check ScDocShellRef xDocSh2 = saveAndReload(xDocSh.get(), nFilter); @@ -3330,7 +3330,7 @@ void ScExportTest::testImageWithSpecialID() { ScDocShellRef xDocSh = loadDoc("images_with_special_IDs.", FORMAT_ODS); - const OString sFailedMessage = OString("Failed on filter: ") + aFilterNames[nFilter]; + const OString sFailedMessage = OStringLiteral("Failed on filter: ") + aFilterNames[nFilter]; CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xDocSh.is()); // Export the document and import again for a check diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 0daed452d103..e697dc700aad 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -4821,7 +4821,7 @@ void Test::testAutoFillSimple() } else { - OString aMsg = OString("wrong value in row: ") + OString::number(nRow); + OString aMsg = "wrong value in row: " + OString::number(nRow); double nVal = m_pDoc->GetValue(0, nRow, 0); CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsg.getStr(), 10.0, nVal); } diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index 55749266ffb5..96c97c5793b9 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -159,7 +159,7 @@ void Test::testFormulaCreateStringFromTokens() bool bInserted = pDBs->getNamedDBs().insert(std::move(pData)); CPPUNIT_ASSERT_MESSAGE( OString( - "Failed to insert \"" + OString(aDBs[i].pName) + "\"").getStr(), + OStringLiteral("Failed to insert \"") + aDBs[i].pName + "\"").getStr(), bInserted); } @@ -6976,7 +6976,7 @@ void Test::testFuncTableRef() ScAddress(2,4,0), ScRangeData::Type::Name, formula::FormulaGrammar::GRAM_NATIVE); bool bInserted = pGlobalNames->insert(pName); CPPUNIT_ASSERT_MESSAGE( - OString("Failed to insert named expression "+ OString(aNames[i].pName) +".").getStr(), bInserted); + OString(OStringLiteral("Failed to insert named expression ") + aNames[i].pName +".").getStr(), bInserted); } } @@ -7150,7 +7150,7 @@ void Test::testFuncTableRef() ScAddress(6,12,0), ScRangeData::Type::Name, formula::FormulaGrammar::GRAM_NATIVE); bool bInserted = pGlobalNames->insert(pName); CPPUNIT_ASSERT_MESSAGE( - OString("Failed to insert named expression "+ OString(aHlNames[i].pName) +".").getStr(), bInserted); + OString(OStringLiteral("Failed to insert named expression ") + aHlNames[i].pName +".").getStr(), bInserted); } } diff --git a/sc/source/filter/ftools/ftools.cxx b/sc/source/filter/ftools/ftools.cxx index c34c446ea482..a116d448d971 100644 --- a/sc/source/filter/ftools/ftools.cxx +++ b/sc/source/filter/ftools/ftools.cxx @@ -117,10 +117,10 @@ rtl_TextEncoding ScfTools::GetSystemTextEncoding() OUString ScfTools::GetHexStr( sal_uInt16 nValue ) { const sal_Char pHex[] = "0123456789ABCDEF"; - OUString aStr = OUString( pHex[ nValue >> 12 ] ) - + OUString( pHex[ (nValue >> 8) & 0x000F ] ) - + OUString( pHex[ (nValue >> 4) & 0x000F ] ) - + OUString( pHex[ nValue & 0x000F ] ); + OUString aStr = OUStringLiteral1( pHex[ nValue >> 12 ] ) + + OUStringLiteral1( pHex[ (nValue >> 8) & 0x000F ] ) + + OUStringLiteral1( pHex[ (nValue >> 4) & 0x000F ] ) + + OUStringLiteral1( pHex[ nValue & 0x000F ] ); return aStr; } diff --git a/sc/source/filter/html/htmlexp.cxx b/sc/source/filter/html/htmlexp.cxx index df24f8f0a219..646b3d281c47 100644 --- a/sc/source/filter/html/htmlexp.cxx +++ b/sc/source/filter/html/htmlexp.cxx @@ -323,7 +323,7 @@ void ScHTMLExport::WriteHeader() if (!xDocProps->getPrintedBy().isEmpty()) { OUT_COMMENT( GLOBSTR( STR_DOC_INFO ) ); - OUString aStrOut = ( GLOBSTR( STR_DOC_PRINTED ) ) + ": "; + OUString aStrOut = GLOBSTR( STR_DOC_PRINTED ) + ": "; lcl_AddStamp( aStrOut, xDocProps->getPrintedBy(), xDocProps->getPrintDate(), *ScGlobal::pLocaleData ); OUT_COMMENT( aStrOut ); diff --git a/sc/source/filter/lotus/lotform.cxx b/sc/source/filter/lotus/lotform.cxx index 360b5da2d40d..9692a95f08ff 100644 --- a/sc/source/filter/lotus/lotform.cxx +++ b/sc/source/filter/lotus/lotform.cxx @@ -62,7 +62,7 @@ void LotusToSc::DoFunc( DefTokenId eOc, sal_uInt8 nCnt, const sal_Char* pExtStri eOc = lcl_KnownAddIn( t ); if( eOc == ocNoName ) - t = OString("L123_") + t; + t = "L123_" + t; } else t = "#UNKNOWN FUNC NAME#"; diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx index 8e3db03ccca0..b6f3b065df45 100644 --- a/sc/source/ui/dbgui/scuiasciiopt.cxx +++ b/sc/source/ui/dbgui/scuiasciiopt.cxx @@ -679,7 +679,7 @@ void ScImportAsciiDlg::SetSeparators() case ' ': pCkbSpace->Check(); break; default: pCkbOther->Check(); - pEdOther->SetText( pEdOther->GetText() + OUString( aSep[i] ) ); + pEdOther->SetText( pEdOther->GetText() + OUStringLiteral1(aSep[i]) ); } } } diff --git a/sc/source/ui/miscdlgs/acredlin.cxx b/sc/source/ui/miscdlgs/acredlin.cxx index 82333e4afbb3..a30c56ef0b00 100644 --- a/sc/source/ui/miscdlgs/acredlin.cxx +++ b/sc/source/ui/miscdlgs/acredlin.cxx @@ -1607,7 +1607,7 @@ IMPL_LINK(ScAcceptChgDlg, CommandHdl, const CommandEvent&, rCEvt, bool) int nSortedCol = rTreeView.get_sort_column(); for (sal_Int32 i = 0; i < 5; ++i) - m_xPopup->set_active(OString("calcsort") + OString::number(i), i == nSortedCol); + m_xPopup->set_active("calcsort" + OString::number(i), i == nSortedCol); m_xPopup->set_sensitive("calcedit", false); diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx index 5c46df802295..c26808a26ece 100644 --- a/sc/source/ui/navipi/content.cxx +++ b/sc/source/ui/navipi/content.cxx @@ -636,7 +636,7 @@ void ScContentTree::Command( const CommandEvent& rCEvt ) else aEntry += pParentWindow->aStrNotActive; ++i; - aDocMenu->InsertItem(i, aEntry, MenuItemBits::AUTOCHECK | MenuItemBits::RADIOCHECK, OString("document") + OString::number(i)); + aDocMenu->InsertItem(i, aEntry, MenuItemBits::AUTOCHECK | MenuItemBits::RADIOCHECK, "document" + OString::number(i)); if ( !bHiddenDoc && aName == aManualDoc ) nPos = i; } @@ -644,7 +644,7 @@ void ScContentTree::Command( const CommandEvent& rCEvt ) } // "active window" ++i; - aDocMenu->InsertItem(i, pParentWindow->aStrActiveWin, MenuItemBits::AUTOCHECK | MenuItemBits::RADIOCHECK, OString("document") + OString::number(i)); + aDocMenu->InsertItem(i, pParentWindow->aStrActiveWin, MenuItemBits::AUTOCHECK | MenuItemBits::RADIOCHECK, "document" + OString::number(i)); if (!bHiddenDoc && aManualDoc.isEmpty()) nPos = i; // hidden document @@ -653,7 +653,7 @@ void ScContentTree::Command( const CommandEvent& rCEvt ) OUString aEntry = aHiddenTitle; aEntry += pParentWindow->aStrHidden; ++i; - aDocMenu->InsertItem(i, aEntry, MenuItemBits::AUTOCHECK | MenuItemBits::RADIOCHECK, OString("document") + OString::number(i)); + aDocMenu->InsertItem(i, aEntry, MenuItemBits::AUTOCHECK | MenuItemBits::RADIOCHECK, "document" + OString::number(i)); if (bHiddenDoc) nPos = i; } diff --git a/sc/source/ui/view/tabview5.cxx b/sc/source/ui/view/tabview5.cxx index 22afcdb908cd..b075b748f0e3 100644 --- a/sc/source/ui/view/tabview5.cxx +++ b/sc/source/ui/view/tabview5.cxx @@ -330,7 +330,7 @@ void ScTabView::TabChanged( bool bSameTabButMoved ) // Invalidate first tools::Rectangle aRectangle(0, 0, 1000000000, 1000000000); - OString sPayload = aRectangle.toString() + OString(", ") + OString::number(aViewData.GetTabNo()); + OString sPayload = aRectangle.toString() + ", " + OString::number(aViewData.GetTabNo()); pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_TILES, sPayload.getStr()); ScModelObj* pModel = comphelper::getUnoTunnelImplementation<ScModelObj>(pViewShell->GetCurrentDocument()); |