From 042c2a24f598cd9405ba98342efcb00098d70b1d Mon Sep 17 00:00:00 2001 From: Matteo Casalin <matteo.casalin@yahoo.com> Date: Thu, 31 Jan 2019 08:14:22 +0100 Subject: 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> --- sw/source/filter/ww8/ww8atr.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sw') 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 + "\""; -- cgit