Use early return

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
This commit is contained in:
Thomas Lauf 2019-04-11 16:07:57 +02:00
parent 6f439097d6
commit b3799ede03

View file

@ -184,17 +184,15 @@ std::pair<int, int> Chart::determineHourRange (
const Interval &filter,
const std::vector<Interval> &tracked)
{
// Default to the full day.
auto first_hour = 0;
auto last_hour = 23;
// If there is no data,
// show the whole day.
if (!tracked.empty ())
// If there is no data, show the whole day.
if (tracked.empty ())
{
return std::make_pair (0, 23);
}
// Get the extreme time range for the filtered data.
first_hour = 23;
last_hour = 0;
auto first_hour = 23;
auto last_hour = 0;
for (Datetime day = filter.start; day < filter.end; day++)
{
@ -233,7 +231,6 @@ std::pair<int, int> Chart::determineHourRange (
first_hour = std::max (first_hour - 1, 0);
last_hour = std::min (last_hour + 1, 23);
}
}
return std::make_pair (first_hour, last_hour);
}