summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeonid Ryzhov <leoryzhov@gmail.com>2022-11-24 22:19:39 +0300
committerHossein <hossein@libreoffice.org>2022-12-19 16:39:27 +0000
commited9eef72e0f616b9c626629c4233b725ca5506ce (patch)
treea47f619a89fd64974245f33e7200c4b6a6255c00
parentd968061f008b954f55ab9a4dd51efd5d0844b543 (diff)
tdf#145538 Use range based for loops
Change-Id: I6d04185f14c3ec72b40426bd881cac80528cc736 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143244 Tested-by: Jenkins Reviewed-by: Hossein <hossein@libreoffice.org>
-rw-r--r--cui/source/customize/SvxNotebookbarConfigPage.cxx5
-rw-r--r--cui/source/dialogs/about.cxx8
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx16
-rw-r--r--editeng/source/lookuptree/Trie.cxx7
4 files changed, 14 insertions, 22 deletions
diff --git a/cui/source/customize/SvxNotebookbarConfigPage.cxx b/cui/source/customize/SvxNotebookbarConfigPage.cxx
index 35dc04aacbaa..c6dda6701133 100644
--- a/cui/source/customize/SvxNotebookbarConfigPage.cxx
+++ b/cui/source/customize/SvxNotebookbarConfigPage.cxx
@@ -407,9 +407,8 @@ void SvxNotebookbarConfigPage::SelectElement()
if (m_xTopLevelListBox->get_count() == 1)
{
- for (std::size_t nIdx = 0; nIdx < aCategoryList.size(); nIdx++)
- m_xTopLevelListBox->append(aCategoryList[nIdx].sUIItemId,
- aCategoryList[nIdx].sDisplayName);
+ for (const auto& rCategory : aCategoryList)
+ m_xTopLevelListBox->append(rCategory.sUIItemId, rCategory.sDisplayName);
}
tools::ULong nStart = 0;
if (aEntries[nStart].sClassId == "sfxlo-PriorityHBox"
diff --git a/cui/source/dialogs/about.cxx b/cui/source/dialogs/about.cxx
index b3911bc61179..41d17b2a06d5 100644
--- a/cui/source/dialogs/about.cxx
+++ b/cui/source/dialogs/about.cxx
@@ -142,12 +142,8 @@ AboutDialog::AboutDialog(weld::Window *pParent)
AboutDialog::~AboutDialog() {}
bool AboutDialog::IsStringValidGitHash(std::u16string_view hash) {
- for (size_t i = 0; i < hash.size(); i++) {
- if (!std::isxdigit(hash[i])) {
- return false;
- }
- }
- return true;
+ return std::all_of(hash.begin(), hash.end(),
+ [](auto &rSymbol) { return std::isxdigit(rSymbol); });
}
OUString AboutDialog::GetVersionString() {
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index e7762753775f..5d897c40f1da 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -1133,11 +1133,11 @@ void DesktopLOKTest::testSheetSelections()
char* pCopiedContent = pDocument->pClass->getTextSelection(pDocument, nullptr, &pUsedMimeType);
std::vector<long> aExpected = {5, 6, 7, 8, 9};
std::istringstream iss(pCopiedContent);
- for (size_t i = 0; i < aExpected.size(); i++)
+ for (const long nIndex : aExpected)
{
std::string token;
iss >> token;
- CPPUNIT_ASSERT_EQUAL(aExpected[i], strtol(token.c_str(), nullptr, 10));
+ CPPUNIT_ASSERT_EQUAL(nIndex, strtol(token.c_str(), nullptr, 10));
}
free(pUsedMimeType);
@@ -1166,11 +1166,11 @@ void DesktopLOKTest::testSheetSelections()
char* pCopiedContent = pDocument->pClass->getTextSelection(pDocument, nullptr, &pUsedMimeType);
std::vector<long> aExpected = { 8 };
std::istringstream iss(pCopiedContent);
- for (size_t i = 0; i < aExpected.size(); i++)
+ for (const long nIndex : aExpected)
{
std::string token;
iss >> token;
- CPPUNIT_ASSERT_EQUAL(aExpected[i], strtol(token.c_str(), nullptr, 10));
+ CPPUNIT_ASSERT_EQUAL(nIndex, strtol(token.c_str(), nullptr, 10));
}
free(pUsedMimeType);
@@ -1237,10 +1237,10 @@ void DesktopLOKTest::testSheetDragDrop()
std::vector<long> aExpected = {1, 2, 3, 4, 5};
std::istringstream aContent(pContent);
std::string token;
- for (size_t i = 0; i < aExpected.size(); i++)
+ for (const long nIndex : aExpected)
{
aContent >> token;
- CPPUNIT_ASSERT_EQUAL(aExpected[i], strtol(token.c_str(), nullptr, 10));
+ CPPUNIT_ASSERT_EQUAL(nIndex, strtol(token.c_str(), nullptr, 10));
}
free(pMimeType);
@@ -1293,10 +1293,10 @@ void DesktopLOKTest::testSheetDragDrop()
std::vector<long> aExpected = {1, 2, 3, 4, 5};
std::istringstream aContent(pContent);
std::string token;
- for (size_t i = 0; i < aExpected.size(); i++)
+ for (const long nIndex : aExpected)
{
aContent >> token;
- CPPUNIT_ASSERT_EQUAL(aExpected[i], strtol(token.c_str(), nullptr, 10));
+ CPPUNIT_ASSERT_EQUAL(nIndex, strtol(token.c_str(), nullptr, 10));
}
free(pMimeType);
diff --git a/editeng/source/lookuptree/Trie.cxx b/editeng/source/lookuptree/Trie.cxx
index d4d3263c72cd..6505c00e43f9 100644
--- a/editeng/source/lookuptree/Trie.cxx
+++ b/editeng/source/lookuptree/Trie.cxx
@@ -114,9 +114,8 @@ TrieNode* TrieNode::traversePath(std::u16string_view sPath)
{
TrieNode* pCurrent = this;
- for ( size_t i = 0; i < sPath.size(); i++ )
+ for ( const auto aCurrentChar : sPath )
{
- sal_Unicode aCurrentChar = sPath[i];
pCurrent = pCurrent->findChild(aCurrentChar);
if ( pCurrent == nullptr )
return nullptr;
@@ -145,11 +144,9 @@ void Trie::insert(std::u16string_view sInputString) const
// traverse the input string and modify the tree with new nodes / characters
TrieNode* pCurrent = mRoot.get();
- sal_Unicode aCurrentChar;
- for ( size_t i = 0; i < sInputString.size(); i++ )
+ for ( const auto aCurrentChar : sInputString )
{
- aCurrentChar = sInputString[i];
TrieNode* pChild = pCurrent->findChild(aCurrentChar);
if ( pChild == nullptr )
{