summaryrefslogtreecommitdiffstats
path: root/cpputools
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@yahoo.com>2018-12-21 18:23:34 +0100
committerMatteo Casalin <matteo.casalin@yahoo.com>2018-12-28 17:10:16 +0100
commitda096e3b0ab93b43c5d33aeed0b90d7fb151f6dc (patch)
treee846136e26e36eda65d9f244e93bac1e114bba17 /cpputools
parentDo not use indexed getToken for a single call (diff)
downloadcore-da096e3b0ab93b43c5d33aeed0b90d7fb151f6dc.tar.gz
core-da096e3b0ab93b43c5d33aeed0b90d7fb151f6dc.zip
Reduce OUString operations and use indexed getToken
Change-Id: I41bc361cbbbf1a446138354eb7bf80729a79bc1f Reviewed-on: https://gerrit.libreoffice.org/65673 Tested-by: Jenkins Reviewed-by: Matteo Casalin <matteo.casalin@yahoo.com>
Diffstat (limited to 'cpputools')
-rw-r--r--cpputools/source/unoexe/unoexe.cxx24
1 files changed, 15 insertions, 9 deletions
diff --git a/cpputools/source/unoexe/unoexe.cxx b/cpputools/source/unoexe/unoexe.cxx
index c6db2c891db2..8392ace881d0 100644
--- a/cpputools/source/unoexe/unoexe.cxx
+++ b/cpputools/source/unoexe/unoexe.cxx
@@ -427,16 +427,24 @@ SAL_IMPLEMENT_MAIN()
if (!aUnoUrl.isEmpty()) // accepting connections
{
- sal_Int32 nIndex = 0, nTokens = 0;
- do { aUnoUrl.getToken( 0, ';', nIndex ); nTokens++; } while( nIndex != -1 );
- if (nTokens != 3 || aUnoUrl.getLength() < 10 ||
- !aUnoUrl.copy( 0, 4 ).equalsIgnoreAsciiCase( "uno:" ))
+ if (aUnoUrl.getLength() < 10 || !aUnoUrl.startsWithIgnoreAsciiCase( "uno:" ))
+ {
+ throw RuntimeException("illegal uno url given!" );
+ }
+
+ sal_Int32 nIndex = 4; // skip initial "uno:"
+ bool bTooFewTokens {false};
+ const OUString aConnectDescr{ aUnoUrl.getToken( 0, ';', nIndex ) }; // uno:CONNECTDESCR;iiop;InstanceName
+ if (nIndex<0) bTooFewTokens = true;
+ const OUString aUnoUrlToken{ aUnoUrl.getToken( 0, ';', nIndex ) };
+ if (nIndex<0) bTooFewTokens = true;
+ const OUString aInstanceName{ aUnoUrl.getToken( 0, ';', nIndex ) };
+
+ // Exactly 3 tokens are required
+ if (bTooFewTokens || nIndex>0)
{
throw RuntimeException("illegal uno url given!" );
}
- nIndex = 0;
- OUString aConnectDescr( aUnoUrl.getToken( 0, ';', nIndex ).copy( 4 ) ); // uno:CONNECTDESCR;iiop;InstanceName
- OUString aInstanceName( aUnoUrl.getToken( 1, ';', nIndex ) );
Reference< XAcceptor > xAcceptor = Acceptor::create(xContext);
@@ -454,8 +462,6 @@ SAL_IMPLEMENT_MAIN()
xContext, aImplName, aLocation, aServiceName, aInitParams,
bSingleInstance, aInstanceName ) );
- nIndex = 0;
- OUString aUnoUrlToken( aUnoUrl.getToken( 1, ';', nIndex ) );
// coverity[loop_top] - not really an infinite loop, we can be instructed to exit via the connection
for (;;)
{