The callback parameter has a specific type, it accepts a document ID and
returns bool, while the template is overly broad.
Details
Details
- Reviewers
ngraham astippich poboiko - Group Reviewers
Baloo - Commits
- R293:5b6fd8fe88b7: [Transaction] Replace template for functor with std::function
Diff Detail
Diff Detail
- Repository
- R293 Baloo
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Comment Actions
I thought about it myself. I googled it a bit (i.e. here) and saw that there might be some quite unwanted runtime overhead because of using std::function. It might be negligible (since we're doing some costly DB operations inside anyways), but I'd prefer if we did some profiling to make sure it's OK.
Comment Actions
There are two causes mentioned why the template may be faster:
- the compiler may be able to inline or even remove a trivial template
- the std::function may need to heap-allocate the space for the bound values (either for captured values of a lambda, or when using std::bind)
Neither applies here. (1.) is obviously not the case.
(2.) does not apply, as the lambda is bound outside the loop, nothing has to be copied or allocated in the loop.