Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6fe3618e authored by Bart Van Assche's avatar Bart Van Assche
Browse files

libhealthloop: Micro-optimize HealthLoop::RegisterEvent()

BoundFunction is an alias for std::function<>. Copying a function object
may be expensive. Use std::move() to avoid copying std::function<>. From
https://engdoc.corp.google.com/eng/doc/devguide/cpp/std_function.md

:
"Generally prefer both accepting and passing by value if ownership is
transferred. Recall that when using value semantics, it's important to
also use std::move() when appropriate."

Bug: 203462310
Change-Id: I9fb87737dd5ce0fbb84bfbbdb0f8bb952dea1fbc
Signed-off-by: default avatarBart Van Assche <bvanassche@google.com>
parent 8bb6819c
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -52,9 +52,9 @@ HealthLoop::~HealthLoop() {
int HealthLoop::RegisterEvent(int fd, BoundFunction func, EventWakeup wakeup) {
    CHECK(!reject_event_register_);

    auto* event_handler =
            event_handlers_
                    .emplace_back(std::make_unique<EventHandler>(EventHandler{this, fd, func}))
    auto* event_handler = event_handlers_
                                  .emplace_back(std::make_unique<EventHandler>(
                                          EventHandler{this, fd, std::move(func)}))
                                  .get();

    struct epoll_event ev;