Skip to content

Commit e12a369

Browse files
committed
Prefer const ref over call by value plus std::move().
1 parent 52f9dcf commit e12a369

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

cores/esp8266/Schedule.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ bool schedule_function(const std::function<void(void)>& fn)
8686
}
8787

8888
bool schedule_recurrent_function_us(const std::function<bool(void)>& fn,
89-
uint32_t repeat_us, std::function<bool(void)> alarm)
89+
uint32_t repeat_us, const std::function<bool(void)>& alarm)
9090
{
9191
assert(repeat_us < decltype(recurrent_fn_t::callNow)::neverExpires); //~26800000us (26.8s)
9292

@@ -98,7 +98,7 @@ bool schedule_recurrent_function_us(const std::function<bool(void)>& fn,
9898
return false;
9999

100100
item->mFunc = fn;
101-
item->alarm = std::move(alarm);
101+
item->alarm = alarm;
102102

103103
esp8266::InterruptLock lockAllInterruptsInThisScope;
104104

cores/esp8266/Schedule.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void run_scheduled_functions();
6161
// * If alarm is used, anytime during scheduling when it returns true,
6262
// any remaining delay from repeat_us is disregarded, and fn is executed.
6363
bool schedule_recurrent_function_us(const std::function<bool(void)>& fn,
64-
uint32_t repeat_us, std::function<bool(void)> alarm = nullptr);
64+
uint32_t repeat_us, const std::function<bool(void)>& alarm = nullptr);
6565

6666
// Test recurrence and run recurrent scheduled functions.
6767
// (internally called at every `yield()` and `loop()`)

0 commit comments

Comments
 (0)