[Libreoffice-commits] core.git: sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Feb 8 18:35:17 UTC 2019
sw/source/filter/ww8/ww8atr.cxx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
New commits:
commit 042c2a24f598cd9405ba98342efcb00098d70b1d
Author: Matteo Casalin <matteo.casalin at yahoo.com>
AuthorDate: Thu Jan 31 08:14:22 2019 +0100
Commit: Matteo Casalin <matteo.casalin at yahoo.com>
CommitDate: Fri Feb 8 19:34:47 2019 +0100
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 at yahoo.com>
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 + "\"";
More information about the Libreoffice-commits
mailing list