Skip to content

Commit ca12a2e

Browse files
author
John Wellbelove
committed
Use etl::clamp for setting value in cyclic_value
1 parent f33c400 commit ca12a2e

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

include/etl/cyclic_value.h

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,7 @@ namespace etl
139139
//*************************************************************************
140140
void set(T value_)
141141
{
142-
if (value_ > Last)
143-
{
144-
value_ = Last;
145-
}
146-
147-
// lower-bound clamp only if First != 0
148-
detail::lower_bound_impl<(First != 0), T, First>::apply(value_);
149-
150-
value = value_;
142+
value = etl::clamp(value_, First, Last);
151143
}
152144

153145
//*************************************************************************
@@ -427,16 +419,7 @@ namespace etl
427419
//*************************************************************************
428420
void set(T value_)
429421
{
430-
if (value_ > last_value)
431-
{
432-
value_ = last_value;
433-
}
434-
else if (value_ < first_value)
435-
{
436-
value_ = first_value;
437-
}
438-
439-
value = value_;
422+
value = etl::clamp(value_, first_value, last_value);
440423
}
441424

442425
//*************************************************************************

0 commit comments

Comments
 (0)