summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-07-20 15:10:40 +0200
committerMike Kaganski <mike.kaganski@collabora.com>2021-07-20 21:50:21 +0200
commita85dfb250ec983b5e325ccd0e0dbef27a75f47ce (patch)
tree8c3956a757b8486f821755aaa6effc3cf2bb6a5d /editeng
parent8e8d3f4db94e0069a1d84378d295268f5037b016 (diff)
Use standard algorithm here
It also compares sizes, so no need for duplicating check. Change-Id: Ica08af55da2ec8acfbeca333d32fe03929ee2cac Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119189 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/editeng/editobj.cxx33
1 files changed, 7 insertions, 26 deletions
diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx
index cf4e474df6b6..b04f05313b3d 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -790,8 +790,7 @@ bool EditTextObjectImpl::Equals( const EditTextObjectImpl& rCompare, bool bCompa
if( this == &rCompare )
return true;
- if( ( aContents.size() != rCompare.aContents.size() ) ||
- ( bComparePool && pPool != rCompare.pPool ) ||
+ if( ( bComparePool && pPool != rCompare.pPool ) ||
( nMetric != rCompare.nMetric ) ||
( nUserType!= rCompare.nUserType ) ||
( nScriptType != rCompare.nScriptType ) ||
@@ -799,36 +798,18 @@ bool EditTextObjectImpl::Equals( const EditTextObjectImpl& rCompare, bool bCompa
( mnRotation != rCompare.mnRotation ) )
return false;
- for (size_t i = 0, n = aContents.size(); i < n; ++i)
- {
- if (!(aContents[i]->Equals( *(rCompare.aContents[i]), bComparePool)))
- return false;
- }
-
- return true;
+ return std::equal(
+ aContents.begin(), aContents.end(), rCompare.aContents.begin(), rCompare.aContents.end(),
+ [bComparePool](const auto& c1, const auto& c2) { return c1->Equals(*c2, bComparePool); });
}
// #i102062#
bool EditTextObjectImpl::isWrongListEqual(const EditTextObject& rComp) const
{
const EditTextObjectImpl& rCompare = static_cast<const EditTextObjectImpl&>(rComp);
- if (aContents.size() != rCompare.aContents.size())
- {
- return false;
- }
-
- for (size_t i = 0, n = aContents.size(); i < n; ++i)
- {
- const ContentInfo& rCandA = *aContents[i];
- const ContentInfo& rCandB = *rCompare.aContents[i];
-
- if(!rCandA.isWrongListEqual(rCandB))
- {
- return false;
- }
- }
-
- return true;
+ return std::equal(
+ aContents.begin(), aContents.end(), rCompare.aContents.begin(), rCompare.aContents.end(),
+ [](const auto& c1, const auto& c2) { return c1->isWrongListEqual(*c2); });
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */