diff options
author | Monty <monty@mariadb.org> | 2018-04-04 12:16:12 +0300 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2018-05-07 00:07:32 +0300 |
commit | 30ebc3ee9efcab635b1f3e14b9198a58ae93c233 (patch) | |
tree | 81e3ad66cd4ec8693964317cbf23515d0e9ecf35 /sql/records.cc | |
parent | a22a339f8e044a1e8df011beb0b4c8f43792ac96 (diff) | |
download | mariadb-git-30ebc3ee9efcab635b1f3e14b9198a58ae93c233.tar.gz |
Add likely/unlikely to speed up execution
Added to:
- if (error)
- Lex
- sql_yacc.yy and sql_yacc_ora.yy
- In header files to alloc() calls
- Added thd argument to thd_net_is_killed()
Diffstat (limited to 'sql/records.cc')
-rw-r--r-- | sql/records.cc | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/sql/records.cc b/sql/records.cc index 16680c7ecf2..244d3b4d962 100644 --- a/sql/records.cc +++ b/sql/records.cc @@ -83,7 +83,7 @@ bool init_read_record_idx(READ_RECORD *info, THD *thd, TABLE *table, table->status=0; /* And it's always found */ if (!table->file->inited && - (error= table->file->ha_index_init(idx, 1))) + unlikely(error= table->file->ha_index_init(idx, 1))) { if (print_error) table->file->print_error(error, MYF(0)); @@ -235,7 +235,7 @@ bool init_read_record(READ_RECORD *info,THD *thd, TABLE *table, reinit_io_cache(info->io_cache,READ_CACHE,0L,0,0); info->ref_pos=table->file->ref; if (!table->file->inited) - if (table->file->ha_rnd_init_with_error(0)) + if (unlikely(table->file->ha_rnd_init_with_error(0))) DBUG_RETURN(1); /* @@ -272,7 +272,7 @@ bool init_read_record(READ_RECORD *info,THD *thd, TABLE *table, else if (filesort && filesort->record_pointers) { DBUG_PRINT("info",("using record_pointers")); - if (table->file->ha_rnd_init_with_error(0)) + if (unlikely(table->file->ha_rnd_init_with_error(0))) DBUG_RETURN(1); info->cache_pos= filesort->record_pointers; info->cache_end= (info->cache_pos+ @@ -285,7 +285,7 @@ bool init_read_record(READ_RECORD *info,THD *thd, TABLE *table, int error; info->read_record_func= rr_index_first; if (!table->file->inited && - (error= table->file->ha_index_init(table->file->keyread, 1))) + unlikely((error= table->file->ha_index_init(table->file->keyread, 1)))) { if (print_error) table->file->print_error(error, MYF(0)); @@ -296,7 +296,7 @@ bool init_read_record(READ_RECORD *info,THD *thd, TABLE *table, { DBUG_PRINT("info",("using rr_sequential")); info->read_record_func= rr_sequential; - if (table->file->ha_rnd_init_with_error(1)) + if (unlikely(table->file->ha_rnd_init_with_error(1))) DBUG_RETURN(1); /* We can use record cache if we don't update dynamic length tables */ if (!table->no_cache && @@ -642,7 +642,7 @@ static int rr_from_cache(READ_RECORD *info) { if (info->cache_pos != info->cache_end) { - if (info->cache_pos[info->error_offset]) + if (unlikely(info->cache_pos[info->error_offset])) { shortget(error,info->cache_pos); if (info->print_error) @@ -688,7 +688,8 @@ static int rr_from_cache(READ_RECORD *info) record=uint3korr(position); position+=3; record_pos=info->cache+record*info->reclength; - if ((error=(int16) info->table->file->ha_rnd_pos(record_pos,info->ref_pos))) + if (unlikely((error= (int16) info->table->file-> + ha_rnd_pos(record_pos,info->ref_pos)))) { record_pos[info->error_offset]=1; shortstore(record_pos,error); |