Kaydet (Commit) 042c2a24 authored tarafından Matteo Casalin's avatar Matteo Casalin

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: 's avatarMatteo Casalin <matteo.casalin@yahoo.com>
üst be75c3ea
......@@ -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 + "\"";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment