You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because the callbacks are passed in as const references, the final step where the callback is inserted into the command queue results in a copy. This is expensive if the callback is a functor object with a lot of state.
m_commands.push({redis_cmd, callback});
If the callbacks were instead passed by value, and forwarded into the command queue via std::move, C++17 copy elision would eliminate the copies.
Because the callbacks are passed in as const references, the final step where the callback is inserted into the command queue results in a copy. This is expensive if the callback is a functor object with a lot of state.
m_commands.push({redis_cmd, callback});
If the callbacks were instead passed by value, and forwarded into the command queue via std::move, C++17 copy elision would eliminate the copies.
m_commands.emplace(redis_cmd, std::move(callback));
This sort of thing is typical with asio callbacks and could be applied here as well.
The text was updated successfully, but these errors were encountered: