writerfilter/source/dmapper/DomainMapper_Impl.cxx |   31 ++++++++++++----------
 1 file changed, 17 insertions(+), 14 deletions(-)

New commits:
commit d2cd7097ab8d8fe1a69b9f6e4a11c978b667951a
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Thu Jan 19 12:04:32 2023 -0500
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Fri Jan 20 03:06:17 2023 +0000

    NFC writerfilter: avoid unnecessary code processing
    
    Early return on useless parameter,
    and conditional processing on missing ID.
    
    Change-Id: Iecf2d7522bd0c1e958f826214368966399be311c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145831
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>

diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 48dfc3434ed4..0b73640fd57f 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -253,27 +253,30 @@ static FieldContextPtr GetParentFieldContext(const 
std::deque<FieldContextPtr>&
 /// Decides if the pInner field inside pOuter is allowed in Writer core, 
depending on their type.
 static bool IsFieldNestingAllowed(const FieldContextPtr& pOuter, const 
FieldContextPtr& pInner)
 {
-    std::optional<FieldId> oOuterFieldId = pOuter->GetFieldId();
-    OUString aCommand = pOuter->GetCommand();
-
-    // Ignore leading space before the field name, but don't accept IFF when 
we check for IF.
-    if (!aCommand.isEmpty() && aCommand[0] == ' ')
-    {
-        aCommand = aCommand.subView(1);
-    }
-
-    if (!oOuterFieldId && aCommand.startsWith("IF "))
+    if (!pInner->GetFieldId())
     {
-        // This will be FIELD_IF once the command is closed.
-        oOuterFieldId = FIELD_IF;
+        return true;
     }
 
+    std::optional<FieldId> oOuterFieldId = pOuter->GetFieldId();
     if (!oOuterFieldId)
     {
-        return true;
+        OUString aCommand = pOuter->GetCommand();
+
+        // Ignore leading space before the field name, but don't accept IFF 
when we check for IF.
+        if (!aCommand.isEmpty() && aCommand[0] == ' ')
+        {
+            aCommand = aCommand.subView(1);
+        }
+
+        if (aCommand.startsWith("IF "))
+        {
+            // This will be FIELD_IF once the command is closed.
+            oOuterFieldId = FIELD_IF;
+        }
     }
 
-    if (!pInner->GetFieldId())
+    if (!oOuterFieldId)
     {
         return true;
     }

Reply via email to