framework/inc/helper/mischelper.hxx |   32 ++++++++++++--------------------
 1 file changed, 12 insertions(+), 20 deletions(-)

New commits:
commit 86e6396acb7683e6916c7a502177ecf232468d78
Author:     Matteo Casalin <[email protected]>
AuthorDate: Wed Feb 27 07:57:25 2019 +0100
Commit:     Matteo Casalin <[email protected]>
CommitDate: Wed Mar 20 07:29:11 2019 +0100

    Simplify: avoid OUString copy() and get just needed tokens
    
    Change-Id: I10c4b59cce39bc4e436d26d8a1d391cb2ec4a922
    Reviewed-on: https://gerrit.libreoffice.org/69236
    Tested-by: Jenkins
    Reviewed-by: Matteo Casalin <[email protected]>

diff --git a/framework/inc/helper/mischelper.hxx 
b/framework/inc/helper/mischelper.hxx
index ab08bbf31f9d..487d0f3d569c 100644
--- a/framework/inc/helper/mischelper.hxx
+++ b/framework/inc/helper/mischelper.hxx
@@ -90,27 +90,19 @@ inline void RetrieveTypeNameFromResourceURL( const 
OUString& aResourceURL, OUStr
     static const char      RESOURCEURL_PREFIX[] = "private:resource/";
     static const sal_Int32 RESOURCEURL_PREFIX_SIZE = 
strlen(RESOURCEURL_PREFIX);
 
-    if (( aResourceURL.startsWith( RESOURCEURL_PREFIX ) ) &&
-        ( aResourceURL.getLength() > RESOURCEURL_PREFIX_SIZE ))
+    if (aResourceURL.startsWith( RESOURCEURL_PREFIX ))
     {
-        OUString aTmpStr( aResourceURL.copy( RESOURCEURL_PREFIX_SIZE ));
-        sal_Int32 nToken = 0;
-        sal_Int32 nPart  = 0;
-        do
-        {
-            OUString sToken = aTmpStr.getToken( 0, '/', nToken);
-            if ( !sToken.isEmpty() )
-            {
-                if ( nPart == 0 )
-                    aType = sToken;
-                else if ( nPart == 1 )
-                    aName = sToken;
-                else
-                    break;
-                nPart++;
-            }
-        }
-        while( nToken >=0 );
+        sal_Int32 nIdx{ RESOURCEURL_PREFIX_SIZE };
+        while (nIdx<aResourceURL.getLength() && aResourceURL[nIdx]=='/') 
++nIdx;
+        if (nIdx>=aResourceURL.getLength())
+            return;
+        aType = aResourceURL.getToken(0, '/', nIdx);
+        if (nIdx<0)
+            return;
+        while (nIdx<aResourceURL.getLength() && aResourceURL[nIdx]=='/') 
++nIdx;
+        if (nIdx>=aResourceURL.getLength())
+            return;
+        aName = aResourceURL.getToken(0, '/', nIdx);
     }
 }
 
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to