Skip to content

Commit 90bd059

Browse files
rockeetfacebook-github-bot
authored andcommitted
use lambda instead of std::bind (#1243)
Summary: std::bind(yield_condition, table) will generate a functor which size is larger than std::function's local buf, thus std::function needs to new/delete memory to store the functor. This PR use the lambda which just capture one pointer(table), which size can fit into std::function's local buf thus new/delete is not needed. Pull Request resolved: #1243 Reviewed By: lth Differential Revision: D40858532 Pulled By: hermanlee fbshipit-source-id: f7431f7
1 parent 238afbb commit 90bd059

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

sql/handler.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2912,7 +2912,7 @@ void handler::ha_statistic_increment(
29122912
(table->in_use->status_var.*offset)++;
29132913
table->in_use->check_limit_rows_examined();
29142914
table->in_use->update_sql_stats_periodic();
2915-
table->in_use->check_yield(std::bind(yield_condition, table));
2915+
table->in_use->check_yield([t = table] { return yield_condition(t); });
29162916
}
29172917
}
29182918

@@ -6502,7 +6502,7 @@ ha_rows handler::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
65026502
while (!seq->next(seq_it, &range)) {
65036503
if (unlikely(thd->killed != 0)) return HA_POS_ERROR;
65046504

6505-
thd->check_yield(std::bind(yield_condition, table));
6505+
thd->check_yield([t = table] { return yield_condition(t); });
65066506

65076507
n_ranges++;
65086508
key_range *min_endp, *max_endp;

sql/sql_class.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2733,7 +2733,7 @@ void THD::restore_sub_statement_state(Sub_statement_state *backup) {
27332733
}
27342734

27352735
void THD::check_yield(std::function<bool()> cond) {
2736-
yield_cond = cond;
2736+
yield_cond = std::move(cond);
27372737
thd_wait_begin(this, THD_WAIT_YIELD);
27382738
thd_wait_end(this);
27392739
yield_cond = nullptr;

0 commit comments

Comments
 (0)