diff options
author | Matteo Casalin <matteo.casalin@yahoo.com> | 2015-09-17 07:59:00 +0200 |
---|---|---|
committer | Matteo Casalin <matteo.casalin@yahoo.com> | 2015-10-27 13:59:07 +0100 |
commit | c3cc574235c7db2214c26860554c725ff3976161 (patch) | |
tree | eaecc56b062db3d6438d942b7f2bb86aa64fd00f /sc/source | |
parent | df3682c2981f9212743e84abc6c75f937011cc28 (diff) |
Simplify by early bail-out
Change-Id: I9210db5196e5c40f450e8bedac2ddd9bd2299f9c
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/ui/dbgui/csvsplits.cxx | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/sc/source/ui/dbgui/csvsplits.cxx b/sc/source/ui/dbgui/csvsplits.cxx index 11ed0bae12a7..aaa0952d6b7b 100644 --- a/sc/source/ui/dbgui/csvsplits.cxx +++ b/sc/source/ui/dbgui/csvsplits.cxx @@ -23,24 +23,26 @@ bool ScCsvSplits::Insert( sal_Int32 nPos ) { - bool bValid = (nPos >= 0); - if( bValid ) - { - iterator aIter = ::std::lower_bound( maVec.begin(), maVec.end(), nPos ); - bValid = (aIter == maVec.end()) || (*aIter != nPos); - if( bValid ) - aIter = maVec.insert( aIter, nPos ); - } - return bValid; + if (nPos < 0) + return false; + + const iterator aIter = ::std::lower_bound( maVec.begin(), maVec.end(), nPos ); + + if (aIter != maVec.end() && *aIter == nPos) + return false; + + maVec.insert( aIter, nPos ); + return true; } bool ScCsvSplits::Remove( sal_Int32 nPos ) { sal_uInt32 nIndex = GetIndex( nPos ); - bool bValid = (nIndex != CSV_VEC_NOTFOUND); - if( bValid ) - maVec.erase( maVec.begin() + nIndex ); - return bValid; + if (nIndex == CSV_VEC_NOTFOUND) + return false; + + maVec.erase( maVec.begin() + nIndex ); + return true; } void ScCsvSplits::RemoveRange( sal_Int32 nPosStart, sal_Int32 nPosEnd ) |