summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2023-01-19 12:04:32 -0500
committerJustin Luth <jluth@mail.com>2023-01-20 03:06:17 +0000
commitd2cd7097ab8d8fe1a69b9f6e4a11c978b667951a (patch)
tree004571b3b66c6627a43567aa8b48ed29fb038dc8 /writerfilter
parent1c638b7ac46d8077994c8483e6becc4a33efd12b (diff)
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 <jluth@mail.com>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx31
1 files changed, 17 insertions, 14 deletions
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;
}