summaryrefslogtreecommitdiff
path: root/vcl/unx
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/unx
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/unx')
-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
4 files changed, 4 insertions, 4 deletions
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() );