Kaydet (Commit) 86e6396a authored tarafından Matteo Casalin's avatar Matteo Casalin

Simplify: avoid OUString copy() and get just needed tokens

Change-Id: I10c4b59cce39bc4e436d26d8a1d391cb2ec4a922
Reviewed-on: https://gerrit.libreoffice.org/69236
Tested-by: Jenkins
Reviewed-by: 's avatarMatteo Casalin <matteo.casalin@yahoo.com>
üst c2668656
......@@ -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);
}
}
......
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