editeng/source/editeng/editobj.cxx | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-)
New commits: commit a85dfb250ec983b5e325ccd0e0dbef27a75f47ce Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Tue Jul 20 15:10:40 2021 +0200 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Tue Jul 20 21:50:21 2021 +0200 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.kagan...@collabora.com> 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: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits