summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2013-10-25 16:43:20 +0200
committerNoel Grandin <noel@peralex.com>2013-10-31 08:34:21 +0200
commite2451bd729d0f1d795a5b689deba65bc4e9d92c6 (patch)
tree4f2356107b0e58db7afda0fc324b9eac49ff68c0 /svtools
parent460b52838fdad0352188bdd877b69cbb5f17ca63 (diff)
Convert indexOf->startsWith and lastIndexOf->endsWith
This is both an optimisation and a cleanup. This converts code like aStr.indexOf("XX") == 0 to aStr.startsWith("XX") and converts code like aStr.lastIndexOf("XXX") == aStr.getLength() - 3 to aStr.endsWith("XXX") Note that in general aStr.lastIndexOf("X") == aStr.getLength() - 1 converts to aStr.isEmpty() || aStr.endsWith("X") so I used the surrounding context to determine if aStr could be empty when modifying the code. Change-Id: I22cb8ca7c2a4d0288b001f72adb27fd63af87669
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/control/inettbc.cxx6
-rw-r--r--svtools/source/graphic/grfmgr.cxx2
-rw-r--r--svtools/source/misc/imageresourceaccess.cxx10
-rw-r--r--svtools/source/uno/popupmenucontrollerbase.cxx2
4 files changed, 10 insertions, 10 deletions
diff --git a/svtools/source/control/inettbc.cxx b/svtools/source/control/inettbc.cxx
index ec9de0deba67..f87f783765ab 100644
--- a/svtools/source/control/inettbc.cxx
+++ b/svtools/source/control/inettbc.cxx
@@ -312,7 +312,7 @@ void SvtMatchContext_Impl::ReadFolder( const OUString& rURL,
sal_Bool bPureHomePath = sal_False;
#ifdef UNX
- bPureHomePath = aText.indexOf( '~' ) == 0 && aText.indexOf( '/' ) == -1;
+ bPureHomePath = aText.startsWith( "~" ) && aText.indexOf( '/' ) == -1;
#endif
sal_Bool bExectMatch = bPureHomePath
@@ -484,7 +484,7 @@ OUString SvtURLBox::ParseSmart( OUString aText, OUString aBaseURL, const OUStrin
INetProtocol eBaseProt = INetURLObject::CompareProtocolScheme( aBaseURL );
// if a base URL is set the string may be parsed relative
- if( aText.indexOf( '/' ) == 0 )
+ if( aText.startsWith( "/" ) )
{
// text starting with slashes means absolute file URLs
OUString aTemp = INetURLObject::GetScheme( eBaseProt );
@@ -1296,7 +1296,7 @@ sal_Bool SvtURLBox_Impl::TildeParsing(
)
{
#ifdef UNX
- if( aText.indexOf( '~' ) == 0 )
+ if( aText.startsWith( "~" ) )
{
OUString aParseTilde;
sal_Bool bTrailingSlash = sal_True; // use trailing slash
diff --git a/svtools/source/graphic/grfmgr.cxx b/svtools/source/graphic/grfmgr.cxx
index 96408bfc33d6..89b6eadb768b 100644
--- a/svtools/source/graphic/grfmgr.cxx
+++ b/svtools/source/graphic/grfmgr.cxx
@@ -1147,7 +1147,7 @@ SvStream& operator<<( SvStream& rOStm, const GraphicObject& rGraphicObj )
GraphicObject GraphicObject::CreateGraphicObjectFromURL( const OUString &rURL )
{
const OUString aURL( rURL ), aPrefix( UNO_NAME_GRAPHOBJ_URLPREFIX );
- if( aURL.indexOf( aPrefix ) == 0 )
+ if( aURL.startsWith( aPrefix ) )
{
// graphic manager url
OString aUniqueID(OUStringToOString(rURL.copy(sizeof(UNO_NAME_GRAPHOBJ_URLPREFIX) - 1), RTL_TEXTENCODING_UTF8));
diff --git a/svtools/source/misc/imageresourceaccess.cxx b/svtools/source/misc/imageresourceaccess.cxx
index 40df75d7e98f..fe6e4740222e 100644
--- a/svtools/source/misc/imageresourceaccess.cxx
+++ b/svtools/source/misc/imageresourceaccess.cxx
@@ -126,11 +126,11 @@ namespace svt
//--------------------------------------------------------------------
bool GraphicAccess::isSupportedURL( const OUString& _rURL )
{
- if ( ( _rURL.indexOfAsciiL( RTL_CONSTASCII_STRINGPARAM( "private:resource/" ) ) == 0 )
- || ( _rURL.indexOfAsciiL( RTL_CONSTASCII_STRINGPARAM( "private:graphicrepository/" ) ) == 0 )
- || ( _rURL.indexOfAsciiL( RTL_CONSTASCII_STRINGPARAM( "private:standardimage/" ) ) == 0 )
- || ( _rURL.indexOfAsciiL( RTL_CONSTASCII_STRINGPARAM( "vnd.sun.star.GraphicObject:" ) ) == 0 )
- || ( _rURL.indexOfAsciiL( RTL_CONSTASCII_STRINGPARAM( "vnd.sun.star.extension://" ) ) == 0 )
+ if ( _rURL.startsWith( "private:resource/" )
+ || _rURL.startsWith( "private:graphicrepository/" )
+ || _rURL.startsWith( "private:standardimage/" )
+ || _rURL.startsWith( "vnd.sun.star.GraphicObject:" )
+ || _rURL.startsWith( "vnd.sun.star.extension://" )
)
return true;
return false;
diff --git a/svtools/source/uno/popupmenucontrollerbase.cxx b/svtools/source/uno/popupmenucontrollerbase.cxx
index 06953fbfa8e9..961d5596ede4 100644
--- a/svtools/source/uno/popupmenucontrollerbase.cxx
+++ b/svtools/source/uno/popupmenucontrollerbase.cxx
@@ -262,7 +262,7 @@ throw( ::com::sun::star::uno::RuntimeException )
rBHelper.addListener( ::getCppuType( &xControl ), xControl );
aLock.reset();
- if ( aURL.Complete.indexOf( m_aBaseURL ) == 0 )
+ if ( aURL.Complete.startsWith( m_aBaseURL ) )
bStatusUpdate = true;
aLock.clear();