PITimer slot optimize
This commit is contained in:
@@ -122,13 +122,13 @@ PITimer::PITimer(): PIObject() {
|
||||
|
||||
PITimer::PITimer(std::function<void(int)> func) {
|
||||
initFirst();
|
||||
ret_func = func;
|
||||
ret_func_delim = std::move(func);
|
||||
}
|
||||
|
||||
|
||||
PITimer::PITimer(std::function<void()> func) {
|
||||
initFirst();
|
||||
ret_func = [func](int) { func(); };
|
||||
ret_func = std::move(func);
|
||||
}
|
||||
|
||||
|
||||
@@ -224,7 +224,8 @@ void PITimer::adjustTimes() {
|
||||
void PITimer::execTick() {
|
||||
if (!isRunning()) return;
|
||||
if (lockRun) lock();
|
||||
if (ret_func) ret_func(1);
|
||||
if (ret_func) ret_func();
|
||||
if (ret_func_delim) ret_func_delim(1);
|
||||
tick(1);
|
||||
tickEvent(1);
|
||||
if (callEvents) maybeCallQueuedEvents();
|
||||
@@ -233,8 +234,8 @@ void PITimer::execTick() {
|
||||
i.tick = 0;
|
||||
if (i.func)
|
||||
i.func(i.delim);
|
||||
else if (ret_func)
|
||||
ret_func(i.delim);
|
||||
else if (ret_func_delim)
|
||||
ret_func_delim(i.delim);
|
||||
tick(i.delim);
|
||||
tickEvent(i.delim);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user