summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@yahoo.com>2019-02-27 07:57:25 +0100
committerMatteo Casalin <matteo.casalin@yahoo.com>2019-03-20 07:29:11 +0100
commit86e6396acb7683e6916c7a502177ecf232468d78 (patch)
tree6a3fdd31300bc5b6ae2a0cbe28efa2a24fa6464b /framework
parentc2668656d68ae173566d836eb4890ac9e77ee974 (diff)
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 <matteo.casalin@yahoo.com>
Diffstat (limited to 'framework')
-rw-r--r--framework/inc/helper/mischelper.hxx32
1 files changed, 12 insertions, 20 deletions
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);
}
}