diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2017-01-07 16:47:58 -0500 |
---|---|---|
committer | Kohei Yoshida <libreoffice@kohei.us> | 2017-01-07 22:39:27 +0000 |
commit | 63ddc8dc4ae1f3c3ee2f860c34886688b0ed2d57 (patch) | |
tree | ba23efe99eac13e092cbf428fb49ee54df4a7602 /package | |
parent | 87f9e8945fde37182bec1e674dd6ccee4133209c (diff) |
Reduce scope by removing unnecessary else clauses.
This makes the code a bit easier to follow.
Change-Id: Ia55d963c97b33dd8462e6084adc4820856e126bf
Reviewed-on: https://gerrit.libreoffice.org/32825
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Kohei Yoshida <libreoffice@kohei.us>
Diffstat (limited to 'package')
-rw-r--r-- | package/source/zippackage/ZipPackage.cxx | 118 |
1 files changed, 59 insertions, 59 deletions
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx index d17fee0b3607..3c6eb4848894 100644 --- a/package/source/zippackage/ZipPackage.cxx +++ b/package/source/zippackage/ZipPackage.cxx @@ -782,76 +782,76 @@ Any SAL_CALL ZipPackage::getByHierarchicalName( const OUString& aName ) if ( ( nIndex = aName.getLength() ) == 1 && *aName.getStr() == '/' ) return makeAny ( uno::Reference < XUnoTunnel > ( m_pRootFolder ) ); - else + + nStreamIndex = aName.lastIndexOf ( '/' ); + bool bFolder = nStreamIndex == nIndex-1; + if ( nStreamIndex != -1 ) { - nStreamIndex = aName.lastIndexOf ( '/' ); - bool bFolder = nStreamIndex == nIndex-1; - if ( nStreamIndex != -1 ) + sDirName = aName.copy ( 0, nStreamIndex ); + aIter = m_aRecent.find ( sDirName ); + if ( aIter != m_aRecent.end() ) { - sDirName = aName.copy ( 0, nStreamIndex ); - aIter = m_aRecent.find ( sDirName ); - if ( aIter != m_aRecent.end() ) + if ( bFolder ) { - if ( bFolder ) - { - sal_Int32 nDirIndex = aName.lastIndexOf ( '/', nStreamIndex ); - sTemp = aName.copy ( nDirIndex == -1 ? 0 : nDirIndex+1, nStreamIndex-nDirIndex-1 ); - if ( sTemp == ( *aIter ).second->getName() ) - return makeAny ( uno::Reference < XUnoTunnel > ( ( *aIter ).second ) ); - else - m_aRecent.erase ( aIter ); - } - else - { - sTemp = aName.copy ( nStreamIndex + 1 ); - if ( ( *aIter ).second->hasByName( sTemp ) ) - return ( *aIter ).second->getByName( sTemp ); - else - m_aRecent.erase( aIter ); - } + sal_Int32 nDirIndex = aName.lastIndexOf ( '/', nStreamIndex ); + sTemp = aName.copy ( nDirIndex == -1 ? 0 : nDirIndex+1, nStreamIndex-nDirIndex-1 ); + if ( sTemp == ( *aIter ).second->getName() ) + return makeAny ( uno::Reference < XUnoTunnel > ( ( *aIter ).second ) ); + + m_aRecent.erase ( aIter ); } - } - else - { - if ( m_pRootFolder->hasByName ( aName ) ) - return m_pRootFolder->getByName ( aName ); - } - nOldIndex = 0; - ZipPackageFolder * pCurrent = m_pRootFolder; - ZipPackageFolder * pPrevious = nullptr; - while ( ( nIndex = aName.indexOf( '/', nOldIndex )) != -1 ) - { - sTemp = aName.copy ( nOldIndex, nIndex - nOldIndex ); - if ( nIndex == nOldIndex ) - break; - if ( pCurrent->hasByName( sTemp ) ) + else { - pPrevious = pCurrent; - pCurrent = pCurrent->doGetByName( sTemp ).pFolder; + sTemp = aName.copy ( nStreamIndex + 1 ); + if ( ( *aIter ).second->hasByName( sTemp ) ) + return ( *aIter ).second->getByName( sTemp ); + + m_aRecent.erase( aIter ); } - else - throw NoSuchElementException(THROW_WHERE ); - nOldIndex = nIndex+1; } - if ( bFolder ) + } + else + { + if ( m_pRootFolder->hasByName ( aName ) ) + return m_pRootFolder->getByName ( aName ); + } + + nOldIndex = 0; + ZipPackageFolder * pCurrent = m_pRootFolder; + ZipPackageFolder * pPrevious = nullptr; + + while ( ( nIndex = aName.indexOf( '/', nOldIndex )) != -1 ) + { + sTemp = aName.copy ( nOldIndex, nIndex - nOldIndex ); + if ( nIndex == nOldIndex ) + break; + if ( pCurrent->hasByName( sTemp ) ) { - if ( nStreamIndex != -1 ) - m_aRecent[sDirName] = pPrevious; - return makeAny ( uno::Reference < XUnoTunnel > ( pCurrent ) ); + pPrevious = pCurrent; + pCurrent = pCurrent->doGetByName( sTemp ).pFolder; } else - { - sTemp = aName.copy( nOldIndex, aName.getLength() - nOldIndex ); - if ( pCurrent->hasByName ( sTemp ) ) - { - if ( nStreamIndex != -1 ) - m_aRecent[sDirName] = pCurrent; - return pCurrent->getByName( sTemp ); - } - else - throw NoSuchElementException(THROW_WHERE ); - } + throw NoSuchElementException(THROW_WHERE ); + nOldIndex = nIndex+1; } + + if ( bFolder ) + { + if ( nStreamIndex != -1 ) + m_aRecent[sDirName] = pPrevious; + return makeAny ( uno::Reference < XUnoTunnel > ( pCurrent ) ); + } + + sTemp = aName.copy( nOldIndex, aName.getLength() - nOldIndex ); + + if ( pCurrent->hasByName ( sTemp ) ) + { + if ( nStreamIndex != -1 ) + m_aRecent[sDirName] = pCurrent; + return pCurrent->getByName( sTemp ); + } + + throw NoSuchElementException(THROW_WHERE); } sal_Bool SAL_CALL ZipPackage::hasByHierarchicalName( const OUString& aName ) |