refactor: replace some C idioms with C++ ones (#5656)

* tidy up legecy practices

* remove undefined std::ignore usage

* avoid extra function stack level in daemon.cc
This commit is contained in:
tearfur
2023-06-23 06:58:16 +08:00
committed by GitHub
parent 699b3d8416
commit 41cfdce6fd
6 changed files with 18 additions and 24 deletions

View File

@@ -66,10 +66,10 @@ void tr_locale_set_global(char const* locale_name) noexcept
{
try
{
std::ignore = std::locale::global(std::locale{ locale_name });
std::locale::global(std::locale{ locale_name });
std::ignore = std::cout.imbue(std::locale{});
std::ignore = std::cerr.imbue(std::locale{});
std::cout.imbue(std::locale{});
std::cerr.imbue(std::locale{});
}
catch (std::exception const&)
{
@@ -274,7 +274,7 @@ double tr_getRatio(uint64_t numerator, uint64_t denominator)
{
if (denominator > 0)
{
return numerator / (double)denominator;
return numerator / static_cast<double>(denominator);
}
if (numerator > 0)
@@ -717,7 +717,7 @@ char* formatter_get_size_str(formatter_units const& u, char* buf, uint64_t bytes
unit = &u[3];
}
double const value = double(bytes) / unit->value;
double const value = static_cast<double>(bytes) / unit->value;
auto const* const units = std::data(unit->name);
auto precision = int{};