summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@yahoo.com>2019-01-31 08:14:22 +0100
committerMatteo Casalin <matteo.casalin@yahoo.com>2019-02-08 19:34:47 +0100
commit042c2a24f598cd9405ba98342efcb00098d70b1d (patch)
treeea93e8705743cc5a0740e696d8a11ccf054d8d0d
parentbe75c3ea3037522d4abcf08d3f383d6df5f7e493 (diff)
Replace always true condition with a more likely one
indexOf is always lower than string length since "not found" is encoded as -1. Original code works correctly anyway since the "not found" case lead to copying the whole string, although this copy is completely unnecessary. Change-Id: Ic5dd995dd0c3f974c77b5bf209ad5e994b044385 Reviewed-on: https://gerrit.libreoffice.org/67320 Tested-by: Jenkins Reviewed-by: Matteo Casalin <matteo.casalin@yahoo.com>
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx4
1 files changed, 2 insertions, 2 deletions
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 07f4967a7247..02085761e3e9 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -2866,9 +2866,9 @@ void AttributeOutputBase::TextField( const SwFormatField& rField )
if (pDocInfoField != nullptr)
{
OUString sFieldname = pDocInfoField->GetFieldName();
- sal_Int32 nIndex = sFieldname.indexOf(':');
- if (nIndex != sFieldname.getLength())
+ const sal_Int32 nIndex = sFieldname.indexOf(':');
+ if (nIndex >= 0)
sFieldname = sFieldname.copy(nIndex + 1);
sStr = "\"" + sFieldname + "\"";