summaryrefslogtreecommitdiff
path: root/vcl
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 /vcl
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 'vcl')
-rw-r--r--vcl/aqua/source/window/salframe.cxx2
-rw-r--r--vcl/generic/fontmanager/fontmanager.cxx4
-rw-r--r--vcl/source/filter/FilterConfigCache.cxx2
-rw-r--r--vcl/unx/generic/printer/ppdparser.cxx2
-rw-r--r--vcl/unx/generic/printer/printerinfomanager.cxx2
-rw-r--r--vcl/unx/gtk/fpicker/SalGtkFolderPicker.cxx2
-rw-r--r--vcl/unx/gtk/fpicker/SalGtkPicker.cxx2
7 files changed, 8 insertions, 8 deletions
diff --git a/vcl/aqua/source/window/salframe.cxx b/vcl/aqua/source/window/salframe.cxx
index 3a3c31175b8a..5508e448ca2f 100644
--- a/vcl/aqua/source/window/salframe.cxx
+++ b/vcl/aqua/source/window/salframe.cxx
@@ -355,7 +355,7 @@ void AquaSalFrame::SetRepresentedURL( const OUString& i_rDocURL )
// #i113170# may not be the main thread if called from UNO API
SalData::ensureThreadAutoreleasePool();
- if( i_rDocURL.indexOfAsciiL( "file:", 5 ) == 0 )
+ if( i_rDocURL.startsWith( "file:" ) )
{
OUString aSysPath;
osl_getSystemPathFromFileURL( i_rDocURL.pData, &aSysPath.pData );
diff --git a/vcl/generic/fontmanager/fontmanager.cxx b/vcl/generic/fontmanager/fontmanager.cxx
index 91e638a592d6..636528a6eff6 100644
--- a/vcl/generic/fontmanager/fontmanager.cxx
+++ b/vcl/generic/fontmanager/fontmanager.cxx
@@ -360,7 +360,7 @@ bool PrintFontManager::PrintFont::readAfmMetrics( MultiAtomProvider* pProvider,
if( m_aStyleName.isEmpty() && pInfo->gfi->fullName && *pInfo->gfi->fullName )
{
OUString aFullName( OStringToOUString( pInfo->gfi->fullName, RTL_TEXTENCODING_ISO_8859_1 ) );
- if( aFullName.indexOf( aFamily ) == 0 )
+ if( aFullName.startsWith( aFamily ) )
m_aStyleName = WhitespaceToSpace( aFullName.copy( aFamily.getLength() ) );
}
@@ -2533,7 +2533,7 @@ std::list< sal_Unicode > PrintFontManager::getUnicodeFromAdobeName( const OStri
if( aRet.begin() == aRet.end() )
{
- if( rName.getLength() == 7 && rName.indexOf( "uni" ) == 0 )
+ if( rName.getLength() == 7 && rName.startsWith( "uni" ) )
{
sal_Unicode aCode = (sal_Unicode)rName.copy( 3 ).toUInt32( 16 );
aRet.push_back( aCode );
diff --git a/vcl/source/filter/FilterConfigCache.cxx b/vcl/source/filter/FilterConfigCache.cxx
index 1e1301a0caec..b2da4d8ed730 100644
--- a/vcl/source/filter/FilterConfigCache.cxx
+++ b/vcl/source/filter/FilterConfigCache.cxx
@@ -99,7 +99,7 @@ OUString FilterConfigCache::FilterConfigCacheEntry::GetShortName()
if ( lExtensionList.getLength() )
{
aShortName = lExtensionList[ 0 ];
- if ( aShortName.indexOf( "*." ) == 0 )
+ if ( aShortName.startsWith( "*." ) )
aShortName = aShortName.replaceAt( 0, 2, "" );
}
return aShortName;
diff --git a/vcl/unx/generic/printer/ppdparser.cxx b/vcl/unx/generic/printer/ppdparser.cxx
index 1fd56cbe37e1..2d1636b026e1 100644
--- a/vcl/unx/generic/printer/ppdparser.cxx
+++ b/vcl/unx/generic/printer/ppdparser.cxx
@@ -552,7 +552,7 @@ OUString PPDParser::getPPDFile( const OUString& rFile )
if( aStream.IsOpen() )
{
OString aLine = aStream.ReadLine();
- if (aLine.indexOfL(RTL_CONSTASCII_STRINGPARAM("*PPD-Adobe")) == 0)
+ if (aLine.startsWith("*PPD-Adobe"))
aRet = aStream.GetFileName();
else
{
diff --git a/vcl/unx/generic/printer/printerinfomanager.cxx b/vcl/unx/generic/printer/printerinfomanager.cxx
index 9f4dfa2870d7..539f64f1de04 100644
--- a/vcl/unx/generic/printer/printerinfomanager.cxx
+++ b/vcl/unx/generic/printer/printerinfomanager.cxx
@@ -1259,7 +1259,7 @@ static void lpgetSysQueueTokenHandler(
while( it != i_rLines.end() )
{
OString aClean( WhitespaceToSpace( *it ) );
- if( aClean.indexOf( aAllAttr, 0 ) == 0 )
+ if( aClean.startsWith( aAllAttr ) )
{
// insert the comma separated entries into the set of printers to use
sal_Int32 nPos = aAllAttr.getLength();
diff --git a/vcl/unx/gtk/fpicker/SalGtkFolderPicker.cxx b/vcl/unx/gtk/fpicker/SalGtkFolderPicker.cxx
index f9adefcd37c3..18d2750b40d0 100644
--- a/vcl/unx/gtk/fpicker/SalGtkFolderPicker.cxx
+++ b/vcl/unx/gtk/fpicker/SalGtkFolderPicker.cxx
@@ -86,7 +86,7 @@ void SAL_CALL SalGtkFolderPicker::setDisplayDirectory( const OUString& aDirector
aTxt = unicodetouri(OUString("file:///."));
}
- if( !aTxt.isEmpty() && aTxt.lastIndexOf('/') == aTxt.getLength() - 1 )
+ if( aTxt.endsWith("/") )
aTxt = aTxt.copy( 0, aTxt.getLength() - 1 );
OSL_TRACE( "setting path to %s", aTxt.getStr() );
diff --git a/vcl/unx/gtk/fpicker/SalGtkPicker.cxx b/vcl/unx/gtk/fpicker/SalGtkPicker.cxx
index 8cddab043376..aa280df9ffde 100644
--- a/vcl/unx/gtk/fpicker/SalGtkPicker.cxx
+++ b/vcl/unx/gtk/fpicker/SalGtkPicker.cxx
@@ -197,7 +197,7 @@ void SAL_CALL SalGtkPicker::implsetDisplayDirectory( const OUString& aDirectory
aTxt = unicodetouri(OUString("file:///."));
}
- if( aTxt.lastIndexOf('/') == aTxt.getLength() - 1 )
+ if( aTxt.endsWith("/") )
aTxt = aTxt.copy( 0, aTxt.getLength() - 1 );
OSL_TRACE( "setting path to %s", aTxt.getStr() );