summaryrefslogtreecommitdiffstats
path: root/sal/rtl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-04-06 10:47:24 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-04-12 10:11:34 +0200
commit992a33313046f4a4d322db9464c474e7429a019a (patch)
tree494143e3070af872027ecaca840516d3101a881c /sal/rtl
parentconvert SwComparePosition to scoped enum (diff)
downloadcore-992a33313046f4a4d322db9464c474e7429a019a.tar.gz
core-992a33313046f4a4d322db9464c474e7429a019a.zip
clang-tidy: readability-else-after-return
run it against sal,cppu,cppuhelper I had to run this multiple times to catch all the cases in each module, and it requires some hand-tweaking of the resulting output - clang-tidy is not very good about cleaning up trailing spaces, and aligning things nicely. Change-Id: I00336345f5f036e12422b98d66526509380c497a Reviewed-on: https://gerrit.libreoffice.org/36194 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sal/rtl')
-rw-r--r--sal/rtl/bootstrap.cxx14
-rw-r--r--sal/rtl/digest.cxx15
-rw-r--r--sal/rtl/math.cxx45
-rw-r--r--sal/rtl/uri.cxx19
-rw-r--r--sal/rtl/ustring.cxx2
5 files changed, 40 insertions, 55 deletions
diff --git a/sal/rtl/bootstrap.cxx b/sal/rtl/bootstrap.cxx
index 6455c35b2aaa..4a5fabfb6836 100644
--- a/sal/rtl/bootstrap.cxx
+++ b/sal/rtl/bootstrap.cxx
@@ -76,10 +76,9 @@ bool resolvePathnameUrl(rtl::OUString * url) {
osl::FileBase::E_None))
{
return true;
- } else {
- *url = rtl::OUString();
- return false;
}
+ *url = rtl::OUString();
+ return false;
}
enum LookupMode {
@@ -537,9 +536,8 @@ bool Bootstrap_Impl::getDirectValue(
if (find(_nameValueList, key, &v)) {
expandValue(value, v, mode, this, key, requestStack);
return true;
- } else {
- return false;
}
+ return false;
}
bool Bootstrap_Impl::getAmbienceValue(
@@ -557,9 +555,8 @@ bool Bootstrap_Impl::getAmbienceValue(
{
expandValue(value, v, mode, nullptr, key, requestStack);
return true;
- } else {
- return false;
}
+ return false;
}
void Bootstrap_Impl::expandValue(
@@ -838,7 +835,8 @@ sal_Unicode read(rtl::OUString const & text, sal_Int32 * pos, bool * escaped) {
*escaped = true;
return static_cast< sal_Unicode >(
(n1 << 12) | (n2 << 8) | (n3 << 4) | n4);
- } else if (*pos < text.getLength()) {
+ }
+ if (*pos < text.getLength()) {
*escaped = true;
return text[(*pos)++];
}
diff --git a/sal/rtl/digest.cxx b/sal/rtl/digest.cxx
index 51cef8198037..068db56b81e8 100644
--- a/sal/rtl/digest.cxx
+++ b/sal/rtl/digest.cxx
@@ -135,8 +135,7 @@ rtlDigestAlgorithm SAL_CALL rtl_digest_queryAlgorithm (rtlDigest Digest)
Digest_Impl *pImpl = static_cast<Digest_Impl *>(Digest);
if (pImpl)
return pImpl->m_algorithm;
- else
- return rtl_Digest_AlgorithmInvalid;
+ return rtl_Digest_AlgorithmInvalid;
}
/*
@@ -148,8 +147,7 @@ sal_uInt32 SAL_CALL rtl_digest_queryLength (rtlDigest Digest)
Digest_Impl *pImpl = static_cast<Digest_Impl *>(Digest);
if (pImpl)
return pImpl->m_length;
- else
- return 0;
+ return 0;
}
/*
@@ -164,8 +162,7 @@ rtlDigestError SAL_CALL rtl_digest_init (
{
if (pImpl->m_init)
return pImpl->m_init (Digest, pData, nDatLen);
- else
- return rtl_Digest_E_None;
+ return rtl_Digest_E_None;
}
return rtl_Digest_E_Argument;
}
@@ -180,8 +177,7 @@ rtlDigestError SAL_CALL rtl_digest_update (
Digest_Impl *pImpl = static_cast<Digest_Impl *>(Digest);
if (pImpl && pImpl->m_update)
return pImpl->m_update (Digest, pData, nDatLen);
- else
- return rtl_Digest_E_Argument;
+ return rtl_Digest_E_Argument;
}
/*
@@ -194,8 +190,7 @@ rtlDigestError SAL_CALL rtl_digest_get (
Digest_Impl *pImpl = static_cast<Digest_Impl *>(Digest);
if (pImpl && pImpl->m_get)
return pImpl->m_get (Digest, pBuffer, nBufLen);
- else
- return rtl_Digest_E_Argument;
+ return rtl_Digest_E_Argument;
}
/*
diff --git a/sal/rtl/math.cxx b/sal/rtl/math.cxx
index 5dc94e0e0c1f..7eeeb85b4013 100644
--- a/sal/rtl/math.cxx
+++ b/sal/rtl/math.cxx
@@ -54,18 +54,16 @@ static double getN10Exp( int nExp )
// because -nExp = nExp
if ( -nExp <= n10Count && -nExp > 0 )
return n10s[1][-nExp-1];
- else
- return pow( 10.0, static_cast<double>( nExp ) );
+ return pow( 10.0, static_cast<double>( nExp ) );
}
- else if ( nExp > 0 )
+ if ( nExp > 0 )
{
if ( nExp <= n10Count )
return n10s[0][nExp-1];
- else
- return pow( 10.0, static_cast<double>( nExp ) );
+ return pow( 10.0, static_cast<double>( nExp ) );
}
- else // ( nExp == 0 )
- return 1.0;
+ // ( nExp == 0 )
+ return 1.0;
}
namespace {
@@ -1144,21 +1142,19 @@ double SAL_CALL rtl_math_asinh( double fX ) SAL_THROW_EXTERN_C()
{
if ( fX == 0.0 )
return 0.0;
- else
+
+ double fSign = 1.0;
+ if ( fX < 0.0 )
{
- double fSign = 1.0;
- if ( fX < 0.0 )
- {
- fX = - fX;
- fSign = -1.0;
- }
- if ( fX < 0.125 )
- return fSign * rtl_math_log1p( fX + fX*fX / (1.0 + sqrt( 1.0 + fX*fX)));
- else if ( fX < 1.25e7 )
- return fSign * log( fX + sqrt( 1.0 + fX*fX));
- else
- return fSign * log( 2.0*fX);
+ fX = - fX;
+ fSign = -1.0;
}
+ if ( fX < 0.125 )
+ return fSign * rtl_math_log1p( fX + fX*fX / (1.0 + sqrt( 1.0 + fX*fX)));
+ if ( fX < 1.25e7 )
+ return fSign * log( fX + sqrt( 1.0 + fX*fX));
+
+ return fSign * log( 2.0*fX);
}
/** improved accuracy of acosh for x large and for x near 1
@@ -1173,14 +1169,13 @@ double SAL_CALL rtl_math_acosh( double fX ) SAL_THROW_EXTERN_C()
::rtl::math::setNan( &fResult );
return fResult;
}
- else if ( fX == 1.0 )
+ if ( fX == 1.0 )
return 0.0;
- else if ( fX < 1.1 )
+ if ( fX < 1.1 )
return rtl_math_log1p( fZ + sqrt( fZ*fZ + 2.0*fZ));
- else if ( fX < 1.25e7 )
+ if ( fX < 1.25e7 )
return log( fX + sqrt( fX*fX - 1.0));
- else
- return log( 2.0*fX);
+ return log( 2.0*fX);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/rtl/uri.cxx b/sal/rtl/uri.cxx
index b00dfb99f472..91653f6cdabe 100644
--- a/sal/rtl/uri.cxx
+++ b/sal/rtl/uri.cxx
@@ -176,7 +176,7 @@ sal_uInt32 readUcs4(sal_Unicode const ** pBegin, sal_Unicode const * pEnd,
return nDstSize == 1
? aDst[0] : rtl::combineSurrogates(aDst[0], aDst[1]);
}
- else if (nInfo == RTL_TEXTTOUNICODE_INFO_SRCBUFFERTOSMALL
+ if (nInfo == RTL_TEXTTOUNICODE_INFO_SRCBUFFERTOSMALL
&& pEnd - p >= 3 && p[0] == cEscapePrefix
&& (nWeight1 = getHexWeight(p[1])) >= 0
&& (nWeight2 = getHexWeight(p[2])) >= 0)
@@ -202,13 +202,11 @@ sal_uInt32 readUcs4(sal_Unicode const ** pBegin, sal_Unicode const * pEnd,
}
return nChar;
}
- else
- {
- *pType = EscapeNo;
- return rtl::isHighSurrogate(nChar) && *pBegin < pEnd
- && rtl::isLowSurrogate(**pBegin) ?
- rtl::combineSurrogates(nChar, *(*pBegin)++) : nChar;
- }
+
+ *pType = EscapeNo;
+ return rtl::isHighSurrogate(nChar) && *pBegin < pEnd
+ && rtl::isLowSurrogate(**pBegin) ?
+ rtl::combineSurrogates(nChar, *(*pBegin)++) : nChar;
}
void writeUcs4(rtl_uString ** pBuffer, sal_Int32 * pCapacity, sal_uInt32 nUtf32)
@@ -305,9 +303,8 @@ bool writeEscapeChar(rtl_uString ** pBuffer, sal_Int32 * pCapacity,
} else {
if (bStrict) {
return false;
- } else {
- writeUcs4(pBuffer, pCapacity, nUtf32);
}
+ writeUcs4(pBuffer, pCapacity, nUtf32);
}
}
return true;
@@ -359,7 +356,7 @@ void parseUriRef(rtl_uString const * pUriRef, Components * pComponents)
pPos = p;
break;
}
- else if (!rtl::isAsciiAlphanumeric(*p) && *p != '+' && *p != '-'
+ if (!rtl::isAsciiAlphanumeric(*p) && *p != '+' && *p != '-'
&& *p != '.')
{
break;
diff --git a/sal/rtl/ustring.cxx b/sal/rtl/ustring.cxx
index 3d157270ef3c..85ac84a97538 100644
--- a/sal/rtl/ustring.cxx
+++ b/sal/rtl/ustring.cxx
@@ -1017,7 +1017,7 @@ void SAL_CALL rtl_uString_internConvert( rtl_uString ** newStr,
rtl_ustring_intern_internal( newStr, pScratch, CANNOT_RETURN );
return;
}
- else if ( (ulen = rtl_canGuessUOutputLength(len, eTextEncoding)) != 0 )
+ if ( (ulen = rtl_canGuessUOutputLength(len, eTextEncoding)) != 0 )
{
rtl_uString *pScratch;
rtl_TextToUnicodeConverter hConverter;