diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-03-07 13:12:49 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-03-07 13:23:49 +0000 |
commit | a998217202106f65e52f743db0cad8209d6ee972 (patch) | |
tree | 56da7576e614de01bee45a1192c43ba389b58634 /stoc | |
parent | 5f33f600f962c2cfaa1ed4994dbc3209a7b09813 (diff) |
return early and drop else
Change-Id: I4887f01c94e6d7d716d2a074d503fca505a4aff8
Diffstat (limited to 'stoc')
-rw-r--r-- | stoc/source/inspect/introspection.cxx | 110 |
1 files changed, 54 insertions, 56 deletions
diff --git a/stoc/source/inspect/introspection.cxx b/stoc/source/inspect/introspection.cxx index 2393dd7e0510..0148540fea64 100644 --- a/stoc/source/inspect/introspection.cxx +++ b/stoc/source/inspect/introspection.cxx @@ -290,90 +290,88 @@ IntrospectionAccessStatic_Impl::IntrospectionAccessStatic_Impl( Reference< XIdlR sal_Int32 IntrospectionAccessStatic_Impl::getPropertyIndex( const OUString& aPropertyName ) const { - sal_Int32 iHashResult = -1; IntrospectionAccessStatic_Impl* pThis = const_cast<IntrospectionAccessStatic_Impl*>(this); IntrospectionNameMap::iterator aIt = pThis->maPropertyNameMap.find( aPropertyName ); if (aIt != pThis->maPropertyNameMap.end()) - iHashResult = (*aIt).second; - return iHashResult; + return aIt->second; + + return -1; } sal_Int32 IntrospectionAccessStatic_Impl::getMethodIndex( const OUString& aMethodName ) const { - sal_Int32 iHashResult = -1; IntrospectionAccessStatic_Impl* pThis = const_cast<IntrospectionAccessStatic_Impl*>(this); IntrospectionNameMap::iterator aIt = pThis->maMethodNameMap.find( aMethodName ); if (aIt != pThis->maMethodNameMap.end()) { - iHashResult = (*aIt).second; + return aIt->second; } + // #95159 Check if full qualified name matches - else + sal_Int32 iHashResult = -1; + sal_Int32 nSearchFrom = aMethodName.getLength(); + while( true ) { - sal_Int32 nSearchFrom = aMethodName.getLength(); - while( true ) - { - // Strategy: Search back until the first '_' is found - sal_Int32 nFound = aMethodName.lastIndexOf( '_', nSearchFrom ); - if( nFound == -1 ) - break; + // Strategy: Search back until the first '_' is found + sal_Int32 nFound = aMethodName.lastIndexOf( '_', nSearchFrom ); + if( nFound == -1 ) + break; - OUString aPureMethodName = aMethodName.copy( nFound + 1 ); + OUString aPureMethodName = aMethodName.copy( nFound + 1 ); - aIt = pThis->maMethodNameMap.find( aPureMethodName ); - if (aIt != pThis->maMethodNameMap.end()) + aIt = pThis->maMethodNameMap.find( aPureMethodName ); + if (aIt != pThis->maMethodNameMap.end()) + { + // Check if it can be a type? + // Problem: Does not work if package names contain _ ?! + OUString aStr = aMethodName.copy( 0, nFound ); + OUString aTypeName = aStr.replace( '_', '.' ); + Reference< XIdlClass > xClass = mxCoreReflection->forName( aTypeName ); + if( xClass.is() ) { - // Check if it can be a type? - // Problem: Does not work if package names contain _ ?! - OUString aStr = aMethodName.copy( 0, nFound ); - OUString aTypeName = aStr.replace( '_', '.' ); - Reference< XIdlClass > xClass = mxCoreReflection->forName( aTypeName ); - if( xClass.is() ) - { - // If this is a valid class it could be the right method + // If this is a valid class it could be the right method - // Could be the right method, type has to be checked - iHashResult = (*aIt).second; + // Could be the right method, type has to be checked + iHashResult = aIt->second; - const Reference<XIdlMethod> xMethod = maAllMethodSeq.at(iHashResult); + const Reference<XIdlMethod> xMethod = maAllMethodSeq.at(iHashResult); - Reference< XIdlClass > xMethClass = xMethod->getDeclaringClass(); - if( xClass->equals( xMethClass ) ) - { - break; - } - else - { - iHashResult = -1; + Reference< XIdlClass > xMethClass = xMethod->getDeclaringClass(); + if( xClass->equals( xMethClass ) ) + { + break; + } + else + { + iHashResult = -1; - // Could also be another method with the same name - // Iterate over all methods - size_t nLen = maAllMethodSeq.size(); - for (size_t i = 0; i < nLen; ++i) + // Could also be another method with the same name + // Iterate over all methods + size_t nLen = maAllMethodSeq.size(); + for (size_t i = 0; i < nLen; ++i) + { + const Reference<XIdlMethod> xMethod2 = maAllMethodSeq[ i ]; + if( xMethod2->getName() == aPureMethodName ) { - const Reference<XIdlMethod> xMethod2 = maAllMethodSeq[ i ]; - if( xMethod2->getName() == aPureMethodName ) - { - Reference< XIdlClass > xMethClass2 = xMethod2->getDeclaringClass(); + Reference< XIdlClass > xMethClass2 = xMethod2->getDeclaringClass(); - if( xClass->equals( xMethClass2 ) ) - { - iHashResult = i; - break; - } + if( xClass->equals( xMethClass2 ) ) + { + iHashResult = i; + break; } } - - if( iHashResult != -1 ) - break; } + + if( iHashResult != -1 ) + break; } } - - nSearchFrom = nFound - 1; - if( nSearchFrom < 0 ) - break; } + + nSearchFrom = nFound - 1; + if( nSearchFrom < 0 ) + break; } return iHashResult; } @@ -2378,7 +2376,7 @@ css::uno::Reference<css::beans::XIntrospectionAccess> Implementation::inspect( } else { - sal_Int32 iHashResult = (*aIt).second; + sal_Int32 iHashResult = aIt->second; Reference<XIdlMethod> xExistingMethod = pAccess->maAllMethodSeq.at(iHashResult); |