clang-tidy: use braced init list

Found with modernize-return-braced-init-list

Signed-off-by: Rosen Penev <rosenp@gmail.com>
main
Rosen Penev 4 years ago committed by Luis Díaz Más
parent 294372f2ad
commit e93ad82734

@ -205,13 +205,13 @@ namespace Exiv2 {
Slice<byte*> makeSlice(DataBuf& buf, size_t begin, size_t end) Slice<byte*> makeSlice(DataBuf& buf, size_t begin, size_t end)
{ {
checkDataBufBounds(buf, end); checkDataBufBounds(buf, end);
return Slice<byte*>(buf.pData_, begin, end); return {buf.pData_, begin, end};
} }
Slice<const byte*> makeSlice(const DataBuf& buf, size_t begin, size_t end) Slice<const byte*> makeSlice(const DataBuf& buf, size_t begin, size_t end)
{ {
checkDataBufBounds(buf, end); checkDataBufBounds(buf, end);
return Slice<const byte*>(buf.pData_, begin, end); return {buf.pData_, begin, end};
} }
std::ostream& operator<<(std::ostream& os, const Rational& r) std::ostream& operator<<(std::ostream& os, const Rational& r)
@ -673,13 +673,15 @@ namespace Exiv2 {
if (ok) return ret; if (ok) return ret;
long l = stringTo<long>(s, ok); long l = stringTo<long>(s, ok);
if (ok) return Rational(l, 1); if (ok)
return {l, 1};
float f = stringTo<float>(s, ok); float f = stringTo<float>(s, ok);
if (ok) return floatToRationalCast(f); if (ok) return floatToRationalCast(f);
bool b = stringTo<bool>(s, ok); bool b = stringTo<bool>(s, ok);
if (ok) return b ? Rational(1, 1) : Rational(0, 1); if (ok)
return {b ? 1 : 0, 1};
// everything failed, return from stringTo<Rational> is probably the best fit // everything failed, return from stringTo<Rational> is probably the best fit
return ret; return ret;
@ -692,7 +694,7 @@ namespace Exiv2 {
#else #else
if (!std::isfinite(f)) { if (!std::isfinite(f)) {
#endif #endif
return Rational(f > 0 ? 1 : -1, 0); return {f > 0 ? 1 : -1, 0};
} }
// Beware: primitive conversion algorithm // Beware: primitive conversion algorithm
int32_t den = 1000000; int32_t den = 1000000;
@ -710,7 +712,7 @@ namespace Exiv2 {
const int32_t nom = static_cast<int32_t>(f * den + rnd); const int32_t nom = static_cast<int32_t>(f * den + rnd);
const int32_t g = gcd(nom, den); const int32_t g = gcd(nom, den);
return Rational(nom / g, den / g); return {nom / g, den / g};
} }
} // namespace Exiv2 } // namespace Exiv2

@ -267,7 +267,7 @@ namespace Exiv2 {
Rational DataValue::toRational(long n) const Rational DataValue::toRational(long n) const
{ {
ok_ = true; ok_ = true;
return Rational(value_[n], 1); return {value_[n], 1};
} }
StringValueBase::StringValueBase(TypeId typeId) StringValueBase::StringValueBase(TypeId typeId)
@ -351,7 +351,7 @@ namespace Exiv2 {
Rational StringValueBase::toRational(long n) const Rational StringValueBase::toRational(long n) const
{ {
ok_ = true; ok_ = true;
return Rational(value_[n], 1); return {value_[n], 1};
} }
StringValue::StringValue() StringValue::StringValue()
@ -930,7 +930,7 @@ namespace Exiv2 {
Rational LangAltValue::toRational(long /*n*/) const Rational LangAltValue::toRational(long /*n*/) const
{ {
ok_ = false; ok_ = false;
return Rational(0, 0); return {0, 0};
} }
LangAltValue* LangAltValue::clone_() const LangAltValue* LangAltValue::clone_() const
@ -1067,7 +1067,7 @@ namespace Exiv2 {
Rational DateValue::toRational(long n) const Rational DateValue::toRational(long n) const
{ {
return Rational(toLong(n), 1); return {toLong(n), 1};
} }
TimeValue::TimeValue() TimeValue::TimeValue()
@ -1251,7 +1251,7 @@ namespace Exiv2 {
Rational TimeValue::toRational(long n) const Rational TimeValue::toRational(long n) const
{ {
return Rational(toLong(n), 1); return {toLong(n), 1};
} }
} // namespace Exiv2 } // namespace Exiv2

Loading…
Cancel
Save