stdpain opened a new issue #5576:
URL: https://github.com/apache/incubator-doris/issues/5576
**Is your feature request related to a problem? Please describe.**
Our current defer operation is based on std:: function But in most C + +
standard libraries, when creating a function, there will be a new overhead,
which is not necessary for the defer operation. But in fact, if we pass in a
lambda expression, we can determine it during compilation, so we can avoid a
new / delete overhead during the defer operation
STL std::funcional implement
```c++
private:
static void
_M_init_functor(_Any_data& __functor, _Functor&& __f, true_type)
{ ::new (__functor._M_access()) _Functor(std::move(__f)); }
static void
_M_init_functor(_Any_data& __functor, _Functor&& __f, false_type)
{ __functor._M_access<_Functor*>() = new _Functor(std::move(__f)); }
```
we could use this code instread of DeferOP
```c++
template <class T>
class Defer {
public:
Defer(T& closure) : _closure(closure) {}
~Defer() { _closure(); }
private:
T& _closure;
};
```
**Describe the solution you'd like**
Here was the bench mark:
https://quick-bench.com/q/4IKpxAA5VEbXVziV1G2Po-ZupSE
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]