summaryrefslogtreecommitdiff
path: root/sql/sql_handler.cc
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2018-04-04 12:16:12 +0300
committerMonty <monty@mariadb.org>2018-05-07 00:07:32 +0300
commit30ebc3ee9efcab635b1f3e14b9198a58ae93c233 (patch)
tree81e3ad66cd4ec8693964317cbf23515d0e9ecf35 /sql/sql_handler.cc
parenta22a339f8e044a1e8df011beb0b4c8f43792ac96 (diff)
downloadmariadb-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/sql_handler.cc')
-rw-r--r--sql/sql_handler.cc29
1 files changed, 14 insertions, 15 deletions
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc
index ddc9c4a99d7..09883d8a0bd 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -345,7 +345,7 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, SQL_HANDLER *reopen)
error= (thd->open_temporary_tables(tables) ||
open_tables(thd, &tables, &counter, 0));
- if (error)
+ if (unlikely(error))
goto err;
table= tables->table;
@@ -371,7 +371,7 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, SQL_HANDLER *reopen)
/* The ticket returned is within a savepoint. Make a copy. */
error= thd->mdl_context.clone_ticket(&table_list->mdl_request);
table_list->table->mdl_ticket= table_list->mdl_request.ticket;
- if (error)
+ if (unlikely(error))
goto err;
}
}
@@ -426,8 +426,7 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, SQL_HANDLER *reopen)
thd->set_n_backup_active_arena(&sql_handler->arena, &backup_arena);
error= table->fill_item_list(&sql_handler->fields);
thd->restore_active_arena(&sql_handler->arena, &backup_arena);
-
- if (error)
+ if (unlikely(error))
goto err;
/* Always read all columns */
@@ -838,7 +837,7 @@ retry:
goto retry;
}
- if (lock_error)
+ if (unlikely(lock_error))
goto err0; // mysql_lock_tables() printed error message already
}
@@ -880,14 +879,14 @@ retry:
case RFIRST:
if (keyname)
{
- if (!(error= table->file->ha_index_or_rnd_end()) &&
- !(error= table->file->ha_index_init(keyno, 1)))
+ if (likely(!(error= table->file->ha_index_or_rnd_end())) &&
+ likely(!(error= table->file->ha_index_init(keyno, 1))))
error= table->file->ha_index_first(table->record[0]);
}
else
{
- if (!(error= table->file->ha_index_or_rnd_end()) &&
- !(error= table->file->ha_rnd_init(1)))
+ if (likely(!(error= table->file->ha_index_or_rnd_end())) &&
+ likely(!(error= table->file->ha_rnd_init(1))))
error= table->file->ha_rnd_next(table->record[0]);
}
mode= RNEXT;
@@ -906,8 +905,8 @@ retry:
/* else fall through */
case RLAST:
DBUG_ASSERT(keyname != 0);
- if (!(error= table->file->ha_index_or_rnd_end()) &&
- !(error= table->file->ha_index_init(keyno, 1)))
+ if (likely(!(error= table->file->ha_index_or_rnd_end())) &&
+ likely(!(error= table->file->ha_index_init(keyno, 1))))
error= table->file->ha_index_last(table->record[0]);
mode=RPREV;
break;
@@ -921,13 +920,13 @@ retry:
{
DBUG_ASSERT(keyname != 0);
- if (!(key= (uchar*) thd->calloc(ALIGN_SIZE(handler->key_len))))
+ if (unlikely(!(key= (uchar*) thd->calloc(ALIGN_SIZE(handler->key_len)))))
goto err;
- if ((error= table->file->ha_index_or_rnd_end()))
+ if (unlikely((error= table->file->ha_index_or_rnd_end())))
break;
key_copy(key, table->record[0], table->key_info + keyno,
handler->key_len);
- if (!(error= table->file->ha_index_init(keyno, 1)))
+ if (unlikely(!(error= table->file->ha_index_init(keyno, 1))))
error= table->file->ha_index_read_map(table->record[0],
key, handler->keypart_map,
ha_rkey_mode);
@@ -940,7 +939,7 @@ retry:
goto err;
}
- if (error)
+ if (unlikely(error))
{
if (error == HA_ERR_RECORD_DELETED)
continue;