refactor: sonarcloud "use if init" statements (#2587)

This commit is contained in:
Charles Kerr
2022-02-07 23:44:31 -06:00
committed by GitHub
parent 8afbfecadb
commit ba14ffa74c
26 changed files with 126 additions and 163 deletions

View File

@@ -271,29 +271,25 @@ bool is_valid_eta(int t)
int compare_eta(int a, int b)
{
int ret;
bool const a_valid = is_valid_eta(a);
bool const b_valid = is_valid_eta(b);
if (!a_valid && !b_valid)
{
ret = 0;
}
else if (!a_valid)
{
ret = -1;
}
else if (!b_valid)
{
ret = 1;
}
else
{
ret = a < b ? 1 : -1;
return 0;
}
return ret;
if (!a_valid)
{
return -1;
}
if (!b_valid)
{
return 1;
}
return a < b ? 1 : -1;
}
int compare_double(double a, double b)
@@ -1319,24 +1315,20 @@ namespace
int gtr_compare_double(double const a, double const b, int decimal_places)
{
int ret;
auto const ia = int64_t(a * pow(10, decimal_places));
auto const ib = int64_t(b * pow(10, decimal_places));
if (ia < ib)
{
ret = -1;
}
else if (ia > ib)
{
ret = 1;
}
else
{
ret = 0;
return -1;
}
return ret;
if (ia > ib)
{
return 1;
}
return 0;
}
void update_foreach(Gtk::TreeModel::Row const& row)