Commit c42414db by Aaron Gokaslan Committed by GitHub

(perf): use a rvalue cast in func_wrapper (#3966)

* (perf): use an rvalue cast in func_wrapper

* Try to clarify comment

* Fix comment typo
parent 918d4481
...@@ -98,8 +98,8 @@ public: ...@@ -98,8 +98,8 @@ public:
explicit func_wrapper(func_handle &&hf) noexcept : hfunc(std::move(hf)) {} explicit func_wrapper(func_handle &&hf) noexcept : hfunc(std::move(hf)) {}
Return operator()(Args... args) const { Return operator()(Args... args) const {
gil_scoped_acquire acq; gil_scoped_acquire acq;
object retval(hfunc.f(std::forward<Args>(args)...)); // casts the returned object as a rvalue to the return type
return retval.template cast<Return>(); return object(hfunc.f(std::forward<Args>(args)...)).template cast<Return>();
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment