editeng/source/editeng/ContentNode.cxx |   32 ++++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)

New commits:
commit 5ebe81f068dba0c141ebe92f64731d0c95179dae
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Mon Mar 25 16:28:39 2024 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Thu Apr 4 04:06:40 2024 +0200

    editeng: make it ContentNode::FindFeature clearer
    
    Change-Id: Ia3498df3cb11b06ac71e3c75839cc98cc0f3d88c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165337
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/editeng/source/editeng/ContentNode.cxx 
b/editeng/source/editeng/ContentNode.cxx
index a02a3fde0d39..08bf250b6c86 100644
--- a/editeng/source/editeng/ContentNode.cxx
+++ b/editeng/source/editeng/ContentNode.cxx
@@ -947,16 +947,20 @@ EditCharAttrib* CharAttribList::FindEmptyAttrib( 
sal_uInt16 nWhich, sal_Int32 nP
     return nullptr;
 }
 
-namespace {
+namespace
+{
 
 class FindByStartPos
 {
     sal_Int32 mnPos;
 public:
-    explicit FindByStartPos(sal_Int32 nPos) : mnPos(nPos) {}
-    bool operator() (const std::unique_ptr<EditCharAttrib>& r) const
+    explicit FindByStartPos(sal_Int32 nPos)
+        : mnPos(nPos)
+    {}
+
+    bool operator() (std::unique_ptr<EditCharAttrib> const& pCharAttrib) const
     {
-        return r->GetStart() >= mnPos;
+        return pCharAttrib->GetStart() >= mnPos;
     }
 };
 
@@ -965,16 +969,28 @@ public:
 const EditCharAttrib* CharAttribList::FindFeature( sal_Int32 nPos ) const
 {
     // First, find the first attribute that starts at or after specified 
position.
-    AttribsType::const_iterator it =
+    AttribsType::const_iterator iterator =
         std::find_if(maAttribs.begin(), maAttribs.end(), FindByStartPos(nPos));
 
-    if (it == maAttribs.end())
+    if (iterator == maAttribs.end())
+    {
         // All attributes are before the specified position.
         return nullptr;
+    }
 
     // And find the first attribute with feature.
-    it = std::find_if(it, maAttribs.end(), [](const 
std::unique_ptr<EditCharAttrib>& aAttrib) { return aAttrib->IsFeature(); } );
-    return it == maAttribs.end() ? nullptr : it->get();
+    iterator = std::find_if(iterator, maAttribs.end(), [](const 
std::unique_ptr<EditCharAttrib>& aAttrib) {
+        return aAttrib->IsFeature();
+    });
+
+    if (iterator == maAttribs.end())
+    {
+        // Couldn't find the feature
+        return nullptr;
+    }
+
+    // Found
+    return iterator->get();
 }
 
 void CharAttribList::DeleteEmptyAttribs()

Reply via email to