Skip to content

Commit

Permalink
clang-tidy: use braced init list
Browse files Browse the repository at this point in the history
Found with modernize-return-braced-init-list

Signed-off-by: Rosen Penev <rosenp@gmail.com>
  • Loading branch information
neheb authored and piponazo committed May 3, 2021
1 parent 294372f commit e93ad82
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
14 changes: 8 additions & 6 deletions src/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,13 @@ namespace Exiv2 {
Slice<byte*> makeSlice(DataBuf& buf, size_t begin, size_t 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)
{
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)
Expand Down Expand Up @@ -673,13 +673,15 @@ namespace Exiv2 {
if (ok) return ret;

long l = stringTo<long>(s, ok);
if (ok) return Rational(l, 1);
if (ok)
return {l, 1};

float f = stringTo<float>(s, ok);
if (ok) return floatToRationalCast(f);

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
return ret;
Expand All @@ -692,7 +694,7 @@ namespace Exiv2 {
#else
if (!std::isfinite(f)) {
#endif
return Rational(f > 0 ? 1 : -1, 0);
return {f > 0 ? 1 : -1, 0};
}
// Beware: primitive conversion algorithm
int32_t den = 1000000;
Expand All @@ -710,7 +712,7 @@ namespace Exiv2 {
const int32_t nom = static_cast<int32_t>(f * den + rnd);
const int32_t g = gcd(nom, den);

return Rational(nom / g, den / g);
return {nom / g, den / g};
}

} // namespace Exiv2
Expand Down
10 changes: 5 additions & 5 deletions src/value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ namespace Exiv2 {
Rational DataValue::toRational(long n) const
{
ok_ = true;
return Rational(value_[n], 1);
return {value_[n], 1};
}

StringValueBase::StringValueBase(TypeId typeId)
Expand Down Expand Up @@ -351,7 +351,7 @@ namespace Exiv2 {
Rational StringValueBase::toRational(long n) const
{
ok_ = true;
return Rational(value_[n], 1);
return {value_[n], 1};
}

StringValue::StringValue()
Expand Down Expand Up @@ -930,7 +930,7 @@ namespace Exiv2 {
Rational LangAltValue::toRational(long /*n*/) const
{
ok_ = false;
return Rational(0, 0);
return {0, 0};
}

LangAltValue* LangAltValue::clone_() const
Expand Down Expand Up @@ -1067,7 +1067,7 @@ namespace Exiv2 {

Rational DateValue::toRational(long n) const
{
return Rational(toLong(n), 1);
return {toLong(n), 1};
}

TimeValue::TimeValue()
Expand Down Expand Up @@ -1251,7 +1251,7 @@ namespace Exiv2 {

Rational TimeValue::toRational(long n) const
{
return Rational(toLong(n), 1);
return {toLong(n), 1};
}

} // namespace Exiv2

0 comments on commit e93ad82

Please sign in to comment.