Kaydet (Commit) c3cc5742 authored tarafından Matteo Casalin's avatar Matteo Casalin

Simplify by early bail-out

Change-Id: I9210db5196e5c40f450e8bedac2ddd9bd2299f9c
üst df3682c2
...@@ -23,24 +23,26 @@ ...@@ -23,24 +23,26 @@
bool ScCsvSplits::Insert( sal_Int32 nPos ) bool ScCsvSplits::Insert( sal_Int32 nPos )
{ {
bool bValid = (nPos >= 0); if (nPos < 0)
if( bValid ) return false;
{
iterator aIter = ::std::lower_bound( maVec.begin(), maVec.end(), nPos ); const iterator aIter = ::std::lower_bound( maVec.begin(), maVec.end(), nPos );
bValid = (aIter == maVec.end()) || (*aIter != nPos);
if( bValid ) if (aIter != maVec.end() && *aIter == nPos)
aIter = maVec.insert( aIter, nPos ); return false;
}
return bValid; maVec.insert( aIter, nPos );
return true;
} }
bool ScCsvSplits::Remove( sal_Int32 nPos ) bool ScCsvSplits::Remove( sal_Int32 nPos )
{ {
sal_uInt32 nIndex = GetIndex( nPos ); sal_uInt32 nIndex = GetIndex( nPos );
bool bValid = (nIndex != CSV_VEC_NOTFOUND); if (nIndex == CSV_VEC_NOTFOUND)
if( bValid ) return false;
maVec.erase( maVec.begin() + nIndex ); maVec.erase( maVec.begin() + nIndex );
return bValid; return true;
} }
void ScCsvSplits::RemoveRange( sal_Int32 nPosStart, sal_Int32 nPosEnd ) void ScCsvSplits::RemoveRange( sal_Int32 nPosStart, sal_Int32 nPosEnd )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment