sfx2/source/doc/doctemplates.cxx |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

New commits:
commit 4fdc99d1b9b9da438c9a10d774951aaedf1c286a
Author:     Matteo Casalin <matteo.casa...@yahoo.com>
AuthorDate: Sat Feb 9 18:34:09 2019 +0100
Commit:     Matteo Casalin <matteo.casa...@yahoo.com>
CommitDate: Wed Feb 13 07:48:50 2019 +0100

    Execute indexOf() only if needed
    
    Change-Id: Ib018761e35841a5128a2ef1a7318ce7fac448e5c
    Reviewed-on: https://gerrit.libreoffice.org/67630
    Tested-by: Jenkins
    Reviewed-by: Matteo Casalin <matteo.casa...@yahoo.com>

diff --git a/sfx2/source/doc/doctemplates.cxx b/sfx2/source/doc/doctemplates.cxx
index b8711f6f25cd..157539132710 100644
--- a/sfx2/source/doc/doctemplates.cxx
+++ b/sfx2/source/doc/doctemplates.cxx
@@ -560,9 +560,12 @@ void SfxDocTplService_Impl::getDirList()
         aURL.SetURL( aDirs.getToken( 0, C_DELIM, nIdx ) );
         maTemplateDirs[i] = aURL.GetMainURL( 
INetURLObject::DecodeMechanism::NONE );
 
-        sal_Int32 nIndex = maTemplateDirs[i].indexOf( aPrefix );
-        if ( nIndex != -1 && xExpander.is() )
+        if ( xExpander.is() )
         {
+            const sal_Int32 nIndex{ maTemplateDirs[i].indexOf( aPrefix ) };
+            if (nIndex<0)
+                continue;
+
             maTemplateDirs[i] = maTemplateDirs[i].replaceAt(nIndex,
                                                             
aPrefix.getLength(),
                                                             OUString());
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to