[PATCH] fdo#62096 - replace some O(U)String compareTo with ==

Artur Dryomov (via Code Review) gerrit at gerrit.libreoffice.org
Tue Apr 16 10:35:20 PDT 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/3422

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/22/3422/1

fdo#62096 - replace some O(U)String compareTo with ==

Change-Id: I98d04d7da4c2b7ea0b769df9c2bfa8c1ad86bf2d
---
M package/source/xstor/xfactory.cxx
M package/source/zippackage/zipfileaccess.cxx
M sal/workben/testfile.cxx
M sd/source/ui/remotecontrol/DiscoveryService.cxx
M sdext/source/pdfimport/wrapper/wrapper.cxx
M sfx2/source/appl/xpackcreator.cxx
M sfx2/source/doc/ownsubfilterservice.cxx
M sot/source/unoolestorage/xolesimplestorage.cxx
M svtools/source/hatchwindow/documentcloser.cxx
M svtools/source/hatchwindow/hatchwindowfactory.cxx
M svx/source/form/datanavi.cxx
M swext/mediawiki/src/com/sun/star/wiki/WikiEditorImpl.java
M vcl/generic/fontmanager/fontcache.cxx
M vcl/unx/generic/dtrans/X11_clipboard.cxx
M vcl/unx/generic/dtrans/X11_droptarget.cxx
M vcl/unx/generic/dtrans/X11_selection.cxx
M vcl/unx/kde/UnxFilePicker.cxx
M vcl/unx/kde4/KDE4FilePicker.cxx
18 files changed, 29 insertions(+), 29 deletions(-)



diff --git a/package/source/xstor/xfactory.cxx b/package/source/xstor/xfactory.cxx
index 8cf91ed..11fb074 100644
--- a/package/source/xstor/xfactory.cxx
+++ b/package/source/xstor/xfactory.cxx
@@ -294,7 +294,7 @@
     uno::Sequence< OUString > aSeq = impl_staticGetSupportedServiceNames();
 
     for ( sal_Int32 nInd = 0; nInd < aSeq.getLength(); nInd++ )
-        if ( ServiceName.compareTo( aSeq[nInd] ) == 0 )
+        if ( ServiceName == aSeq[nInd] )
             return sal_True;
 
     return sal_False;
diff --git a/package/source/zippackage/zipfileaccess.cxx b/package/source/zippackage/zipfileaccess.cxx
index 09a6e89..4365482 100644
--- a/package/source/zippackage/zipfileaccess.cxx
+++ b/package/source/zippackage/zipfileaccess.cxx
@@ -469,7 +469,7 @@
     uno::Sequence< OUString > aSeq = impl_staticGetSupportedServiceNames();
 
     for ( sal_Int32 nInd = 0; nInd < aSeq.getLength(); nInd++ )
-        if ( ServiceName.compareTo( aSeq[nInd] ) == 0 )
+        if ( ServiceName == aSeq[nInd] )
             return sal_True;
 
     return sal_False;
diff --git a/sal/workben/testfile.cxx b/sal/workben/testfile.cxx
index 473e25a..f4b1df9 100644
--- a/sal/workben/testfile.cxx
+++ b/sal/workben/testfile.cxx
@@ -1760,7 +1760,7 @@
         }
 
 
-        if ( str1[0].compareTo(str1[1]) == 0 )
+        if ( str1[0] == str1[1] )
             print_error( rtl::OString( "Reset" ),FileBase::E_None );
         else
             print_error( rtl::OString( "Reset" ),FileBase::E_invalidError );
diff --git a/sd/source/ui/remotecontrol/DiscoveryService.cxx b/sd/source/ui/remotecontrol/DiscoveryService.cxx
index a19cb32..e18b89f 100644
--- a/sd/source/ui/remotecontrol/DiscoveryService.cxx
+++ b/sd/source/ui/remotecontrol/DiscoveryService.cxx
@@ -93,7 +93,7 @@
         socklen_t aLen = sizeof( aAddr );
         recvfrom( mSocket, aBuffer, BUFFER_SIZE, 0, (sockaddr*) &aAddr, &aLen );
         OString aString( aBuffer, strlen( "LOREMOTE_SEARCH" ) );
-        if ( aString.compareTo( "LOREMOTE_SEARCH" ) == 0 )
+        if ( aString == "LOREMOTE_SEARCH" )
         {
             OStringBuffer aStringBuffer("LOREMOTE_ADVERTISE\n");
             aStringBuffer.append( OUStringToOString(
diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx b/sdext/source/pdfimport/wrapper/wrapper.cxx
index 87f2b85..622995b 100644
--- a/sdext/source/pdfimport/wrapper/wrapper.cxx
+++ b/sdext/source/pdfimport/wrapper/wrapper.cxx
@@ -297,7 +297,7 @@
 {
     const OString aSubPathMarker( "subpath" );
 
-    if( 0 != readNextToken().compareTo( aSubPathMarker ) )
+    if( readNextToken() != aSubPathMarker )
         OSL_PRECOND(false, "broken path");
 
     basegfx::B2DPolyPolygon aResult;
@@ -313,7 +313,7 @@
         sal_Int32 nDummy=m_nCharIndex;
         OString aCurrToken( m_aLine.getToken(m_nNextToken,' ',nDummy) );
 
-        while( m_nCharIndex != -1 && 0 != aCurrToken.compareTo(aSubPathMarker) )
+        while( m_nCharIndex != -1 && aCurrToken != aSubPathMarker )
         {
             sal_Int32 nCurveFlag;
             double    nX, nY;
@@ -634,11 +634,11 @@
     const sal_Int32 nImageSize( readInt32() );
 
     OUString           aFileName;
-    if( aToken.compareTo( aPngMarker ) == 0 )
+    if( aToken == aPngMarker )
         aFileName = aPngFile;
-    else if( aToken.compareTo( aJpegMarker ) == 0 )
+    else if( aToken == aJpegMarker )
         aFileName = aJpegFile;
-    else if( aToken.compareTo( aPbmMarker ) == 0 )
+    else if( aToken == aPbmMarker )
         aFileName = aPbmFile;
     else
     {
diff --git a/sfx2/source/appl/xpackcreator.cxx b/sfx2/source/appl/xpackcreator.cxx
index c71d291..c7fef6e 100644
--- a/sfx2/source/appl/xpackcreator.cxx
+++ b/sfx2/source/appl/xpackcreator.cxx
@@ -178,7 +178,7 @@
     uno::Sequence< OUString > aSeq = impl_getStaticSupportedServiceNames();
 
     for ( sal_Int32 nInd = 0; nInd < aSeq.getLength(); nInd++ )
-        if ( ServiceName.compareTo( aSeq[nInd] ) == 0 )
+        if ( ServiceName == aSeq[nInd] )
             return sal_True;
 
     return sal_False;
diff --git a/sfx2/source/doc/ownsubfilterservice.cxx b/sfx2/source/doc/ownsubfilterservice.cxx
index 3cad598..4a03b1a 100644
--- a/sfx2/source/doc/ownsubfilterservice.cxx
+++ b/sfx2/source/doc/ownsubfilterservice.cxx
@@ -138,7 +138,7 @@
     uno::Sequence< OUString > aSeq = impl_getStaticSupportedServiceNames();
 
     for ( sal_Int32 nInd = 0; nInd < aSeq.getLength(); nInd++ )
-        if ( ServiceName.compareTo( aSeq[nInd] ) == 0 )
+        if ( ServiceName == aSeq[nInd] )
             return sal_True;
 
     return sal_False;
diff --git a/sot/source/unoolestorage/xolesimplestorage.cxx b/sot/source/unoolestorage/xolesimplestorage.cxx
index 3141915..ea0b9d7 100644
--- a/sot/source/unoolestorage/xolesimplestorage.cxx
+++ b/sot/source/unoolestorage/xolesimplestorage.cxx
@@ -787,7 +787,7 @@
     uno::Sequence< OUString > aSeq = impl_staticGetSupportedServiceNames();
 
     for ( sal_Int32 nInd = 0; nInd < aSeq.getLength(); nInd++ )
-        if ( ServiceName.compareTo( aSeq[nInd] ) == 0 )
+        if ( ServiceName == aSeq[nInd] )
             return sal_True;
 
     return sal_False;
diff --git a/svtools/source/hatchwindow/documentcloser.cxx b/svtools/source/hatchwindow/documentcloser.cxx
index 3523304..c35fd3f 100644
--- a/svtools/source/hatchwindow/documentcloser.cxx
+++ b/svtools/source/hatchwindow/documentcloser.cxx
@@ -235,7 +235,7 @@
     uno::Sequence< OUString > aSeq = impl_staticGetSupportedServiceNames();
 
     for ( sal_Int32 nInd = 0; nInd < aSeq.getLength(); nInd++ )
-        if ( ServiceName.compareTo( aSeq[nInd] ) == 0 )
+        if ( ServiceName == aSeq[nInd] )
             return sal_True;
 
     return sal_False;
diff --git a/svtools/source/hatchwindow/hatchwindowfactory.cxx b/svtools/source/hatchwindow/hatchwindowfactory.cxx
index 5f93ebd..51566f4 100644
--- a/svtools/source/hatchwindow/hatchwindowfactory.cxx
+++ b/svtools/source/hatchwindow/hatchwindowfactory.cxx
@@ -80,7 +80,7 @@
     uno::Sequence< OUString > aSeq = impl_staticGetSupportedServiceNames();
 
     for ( sal_Int32 nInd = 0; nInd < aSeq.getLength(); nInd++ )
-        if ( ServiceName.compareTo( aSeq[nInd] ) == 0 )
+        if ( ServiceName == aSeq[nInd] )
             return sal_True;
 
     return sal_False;
diff --git a/svx/source/form/datanavi.cxx b/svx/source/form/datanavi.cxx
index 82e46e7..8ec2242 100644
--- a/svx/source/form/datanavi.cxx
+++ b/svx/source/form/datanavi.cxx
@@ -1368,7 +1368,7 @@
         const PropertyValue* pPropsEnd = pProps + _xPropSeq.getLength();
         for ( ; pProps != pPropsEnd; ++pProps )
         {
-            if ( sInstModel.compareTo( pProps->Name ) == 0 )
+            if ( sInstModel == pProps->Name )
             {
                 Reference< css::xml::dom::XNode > xRoot;
                 if ( pProps->Value >>= xRoot )
@@ -1395,9 +1395,9 @@
                     }
                 }
             }
-            else if ( sInstName.compareTo( pProps->Name ) == 0 && ( pProps->Value >>= sTemp ) )
+            else if ( sInstName == pProps->Name && ( pProps->Value >>= sTemp ) )
                 m_sInstanceName = sRet = sTemp;
-            else if ( sInstURL.compareTo( pProps->Name ) == 0 && ( pProps->Value >>= sTemp ) )
+            else if ( sInstURL == pProps->Name && ( pProps->Value >>= sTemp ) )
                 m_sInstanceURL = sTemp;
         }
 
@@ -2203,7 +2203,7 @@
         const PropertyValue* pPropsEnd = pProps + _xPropSeq.getLength();
         for ( ; pProps != pPropsEnd; ++pProps )
         {
-            if ( sID.compareTo( pProps->Name ) == 0 )
+            if ( sID == pProps->Name )
             {
                 pProps->Value >>= sInstName;
                 break;
diff --git a/swext/mediawiki/src/com/sun/star/wiki/WikiEditorImpl.java b/swext/mediawiki/src/com/sun/star/wiki/WikiEditorImpl.java
index 03e2604..0b37a65 100644
--- a/swext/mediawiki/src/com/sun/star/wiki/WikiEditorImpl.java
+++ b/swext/mediawiki/src/com/sun/star/wiki/WikiEditorImpl.java
@@ -146,7 +146,7 @@
     {
         final com.sun.star.util.URL myURL = aURL;
         //logger.log( Level.INFO, "received dispatch request for: "+aURL.Complete );
-        if ( aURL.Protocol.compareTo( protocolName ) == 0 )
+        if ( aURL.Protocol == protocolName )
         {
             /*
             synchronized( this )
@@ -158,7 +158,7 @@
 
             try
             {
-                if ( myURL.Path.compareTo( "send" ) == 0 )
+                if ( myURL.Path == "send" )
                 {
                     sendArticle();
                 }
diff --git a/vcl/generic/fontmanager/fontcache.cxx b/vcl/generic/fontmanager/fontcache.cxx
index b2a2af5..0d14d48 100644
--- a/vcl/generic/fontmanager/fontcache.cxx
+++ b/vcl/generic/fontmanager/fontcache.cxx
@@ -264,10 +264,10 @@
     do
     {
         aStream.ReadLine( aLine );
-        if( aLine.compareTo( "FontCacheDirectory:" ) == 0 ||
-            aLine.compareTo( "EmptyFontCacheDirectory:" ) == 0 )
+        if( aLine == "FontCacheDirectory:" ||
+            aLine == "EmptyFontCacheDirectory:" )
         {
-            bool bEmpty = (aLine.compareTo( "Empty" ) == 0);
+            bool bEmpty = (aLine == "Empty" );
             sal_Int32 nSearchIndex = bEmpty ? 24 : 19;
 
             OString aDir;
@@ -309,7 +309,7 @@
                 m_aCache[ nDir ].m_bUserOverrideOnly = bKeepOnlyUserOverridden;
             }
         }
-        else if( pDir && aLine.compareTo( "File:" ) == 0 )
+        else if( pDir && aLine == "File:")
         {
             OString aFile( aLine.copy( 5 ) );
             aStream.ReadLine( aLine );
diff --git a/vcl/unx/generic/dtrans/X11_clipboard.cxx b/vcl/unx/generic/dtrans/X11_clipboard.cxx
index 82f1ce9..6325e19 100644
--- a/vcl/unx/generic/dtrans/X11_clipboard.cxx
+++ b/vcl/unx/generic/dtrans/X11_clipboard.cxx
@@ -259,7 +259,7 @@
     Sequence < OUString > SupportedServicesNames = X11Clipboard_getSupportedServiceNames();
 
     for ( sal_Int32 n = SupportedServicesNames.getLength(); n--; )
-        if (SupportedServicesNames[n].compareTo(ServiceName) == 0)
+        if (SupportedServicesNames[n] == ServiceName)
             return sal_True;
 
     return sal_False;
diff --git a/vcl/unx/generic/dtrans/X11_droptarget.cxx b/vcl/unx/generic/dtrans/X11_droptarget.cxx
index f262003..b2e76aa 100644
--- a/vcl/unx/generic/dtrans/X11_droptarget.cxx
+++ b/vcl/unx/generic/dtrans/X11_droptarget.cxx
@@ -202,7 +202,7 @@
     Sequence < OUString > SupportedServicesNames = Xdnd_dropTarget_getSupportedServiceNames();
 
     for ( sal_Int32 n = SupportedServicesNames.getLength(); n--; )
-        if (SupportedServicesNames[n].compareTo(ServiceName) == 0)
+        if (SupportedServicesNames[n] == ServiceName)
             return sal_True;
 
     return sal_False;
diff --git a/vcl/unx/generic/dtrans/X11_selection.cxx b/vcl/unx/generic/dtrans/X11_selection.cxx
index 90e1492..9b8c4ff 100644
--- a/vcl/unx/generic/dtrans/X11_selection.cxx
+++ b/vcl/unx/generic/dtrans/X11_selection.cxx
@@ -4151,7 +4151,7 @@
     Sequence < OUString > SupportedServicesNames = Xdnd_getSupportedServiceNames();
 
     for ( sal_Int32 n = SupportedServicesNames.getLength(); n--; )
-        if (SupportedServicesNames[n].compareTo(ServiceName) == 0)
+        if (SupportedServicesNames[n] == ServiceName)
             return sal_True;
 
     return sal_False;
diff --git a/vcl/unx/kde/UnxFilePicker.cxx b/vcl/unx/kde/UnxFilePicker.cxx
index 5ccc842..706d095 100644
--- a/vcl/unx/kde/UnxFilePicker.cxx
+++ b/vcl/unx/kde/UnxFilePicker.cxx
@@ -660,7 +660,7 @@
 
     for ( sal_Int32 n = SupportedServicesNames.getLength(); n--; )
     {
-        if ( SupportedServicesNames[n].compareTo( ServiceName ) == 0 )
+        if ( SupportedServicesNames[n] == ServiceName )
             return sal_True;
     }
 
diff --git a/vcl/unx/kde4/KDE4FilePicker.cxx b/vcl/unx/kde4/KDE4FilePicker.cxx
index d2731b0..4e3d840 100644
--- a/vcl/unx/kde4/KDE4FilePicker.cxx
+++ b/vcl/unx/kde4/KDE4FilePicker.cxx
@@ -712,7 +712,7 @@
 
     for ( sal_Int32 n = SupportedServicesNames.getLength(); n--; )
     {
-        if ( SupportedServicesNames[n].compareTo( ServiceName ) == 0 )
+        if ( SupportedServicesNames[n] == ServiceName )
             return sal_True;
     }
 

-- 
To view, visit https://gerrit.libreoffice.org/3422
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I98d04d7da4c2b7ea0b769df9c2bfa8c1ad86bf2d
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Artur Dryomov <artur.dryomov at gmail.com>



More information about the LibreOffice mailing list