From e2451bd729d0f1d795a5b689deba65bc4e9d92c6 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 25 Oct 2013 16:43:20 +0200 Subject: 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 --- svtools/source/misc/imageresourceaccess.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'svtools/source/misc') 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; -- cgit