mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
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()
This commit is contained in:
@ -1174,8 +1174,8 @@ Sql_condition* THD::raise_condition(uint sql_errno,
|
||||
require memory allocation and therefore might fail. Non fatal out of
|
||||
memory errors can occur if raised by SIGNAL/RESIGNAL statement.
|
||||
*/
|
||||
if (!(is_fatal_error && (sql_errno == EE_OUTOFMEMORY ||
|
||||
sql_errno == ER_OUTOFMEMORY)))
|
||||
if (likely(!(is_fatal_error && (sql_errno == EE_OUTOFMEMORY ||
|
||||
sql_errno == ER_OUTOFMEMORY))))
|
||||
{
|
||||
cond= da->push_warning(this, sql_errno, sqlstate, level, ucid, msg);
|
||||
}
|
||||
@ -2378,12 +2378,12 @@ bool THD::convert_string(LEX_STRING *to, CHARSET_INFO *to_cs,
|
||||
DBUG_ENTER("THD::convert_string");
|
||||
size_t new_length= to_cs->mbmaxlen * from_length;
|
||||
uint errors;
|
||||
if (alloc_lex_string(to, new_length + 1))
|
||||
if (unlikely(alloc_lex_string(to, new_length + 1)))
|
||||
DBUG_RETURN(true); // EOM
|
||||
to->length= copy_and_convert((char*) to->str, new_length, to_cs,
|
||||
from, from_length, from_cs, &errors);
|
||||
to->str[to->length]= 0; // Safety
|
||||
if (errors && lex->parse_vcol_expr)
|
||||
if (unlikely(errors) && lex->parse_vcol_expr)
|
||||
{
|
||||
my_error(ER_BAD_DATA, MYF(0),
|
||||
ErrConvString(from, from_length, from_cs).ptr(),
|
||||
@ -2485,7 +2485,8 @@ bool THD::copy_with_error(CHARSET_INFO *dstcs, LEX_STRING *dst,
|
||||
bool THD::convert_string(String *s, CHARSET_INFO *from_cs, CHARSET_INFO *to_cs)
|
||||
{
|
||||
uint dummy_errors;
|
||||
if (convert_buffer.copy(s->ptr(), s->length(), from_cs, to_cs, &dummy_errors))
|
||||
if (unlikely(convert_buffer.copy(s->ptr(), s->length(), from_cs, to_cs,
|
||||
&dummy_errors)))
|
||||
return TRUE;
|
||||
/* If convert_buffer >> s copying is more efficient long term */
|
||||
if (convert_buffer.alloced_length() >= convert_buffer.length() * 2 ||
|
||||
@ -3063,7 +3064,7 @@ bool select_send::send_eof()
|
||||
Don't send EOF if we're in error condition (which implies we've already
|
||||
sent or are sending an error)
|
||||
*/
|
||||
if (thd->is_error())
|
||||
if (unlikely(thd->is_error()))
|
||||
return TRUE;
|
||||
::my_eof(thd);
|
||||
is_result_set_started= 0;
|
||||
@ -3078,10 +3079,11 @@ bool select_send::send_eof()
|
||||
bool select_to_file::send_eof()
|
||||
{
|
||||
int error= MY_TEST(end_io_cache(&cache));
|
||||
if (mysql_file_close(file, MYF(MY_WME)) || thd->is_error())
|
||||
if (unlikely(mysql_file_close(file, MYF(MY_WME))) ||
|
||||
unlikely(thd->is_error()))
|
||||
error= true;
|
||||
|
||||
if (!error && !suppress_my_ok)
|
||||
if (likely(!error) && !suppress_my_ok)
|
||||
{
|
||||
::my_ok(thd,row_count);
|
||||
}
|
||||
@ -3343,7 +3345,7 @@ int select_export::send_data(List<Item> &items)
|
||||
res->charset(),
|
||||
res->ptr(), res->length());
|
||||
error_pos= copier.most_important_error_pos();
|
||||
if (error_pos)
|
||||
if (unlikely(error_pos))
|
||||
{
|
||||
char printable_buff[32];
|
||||
convert_to_printable(printable_buff, sizeof(printable_buff),
|
||||
@ -4179,7 +4181,7 @@ bool select_dumpvar::send_eof()
|
||||
Don't send EOF if we're in error condition (which implies we've already
|
||||
sent or are sending an error)
|
||||
*/
|
||||
if (thd->is_error())
|
||||
if (unlikely(thd->is_error()))
|
||||
return true;
|
||||
|
||||
if (!suppress_my_ok)
|
||||
@ -4315,9 +4317,8 @@ void thd_increment_bytes_sent(void *thd, size_t length)
|
||||
}
|
||||
}
|
||||
|
||||
my_bool thd_net_is_killed()
|
||||
my_bool thd_net_is_killed(THD *thd)
|
||||
{
|
||||
THD *thd= current_thd;
|
||||
return thd && thd->killed ? 1 : 0;
|
||||
}
|
||||
|
||||
@ -4785,7 +4786,7 @@ TABLE *open_purge_table(THD *thd, const char *db, size_t dblen,
|
||||
/* we don't recover here */
|
||||
DBUG_ASSERT(!error || !ot_ctx.can_recover_from_failed_open());
|
||||
|
||||
if (error)
|
||||
if (unlikely(error))
|
||||
close_thread_tables(thd);
|
||||
|
||||
DBUG_RETURN(error ? NULL : tl->table);
|
||||
@ -6407,7 +6408,8 @@ int THD::decide_logging_format(TABLE_LIST *tables)
|
||||
clear_binlog_local_stmt_filter();
|
||||
}
|
||||
|
||||
if (error) {
|
||||
if (unlikely(error))
|
||||
{
|
||||
DBUG_PRINT("info", ("decision: no logging since an error was generated"));
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
@ -7249,8 +7251,11 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg,
|
||||
top-most close_thread_tables().
|
||||
*/
|
||||
if (this->locked_tables_mode <= LTM_LOCK_TABLES)
|
||||
if (int error= binlog_flush_pending_rows_event(TRUE, is_trans))
|
||||
{
|
||||
int error;
|
||||
if (unlikely(error= binlog_flush_pending_rows_event(TRUE, is_trans)))
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
/*
|
||||
Warnings for unsafe statements logged in statement format are
|
||||
@ -7518,7 +7523,7 @@ wait_for_commit::wait_for_prior_commit2(THD *thd)
|
||||
thd->ENTER_COND(&COND_wait_commit, &LOCK_wait_commit,
|
||||
&stage_waiting_for_prior_transaction_to_commit,
|
||||
&old_stage);
|
||||
while ((loc_waitee= this->waitee) && !thd->check_killed())
|
||||
while ((loc_waitee= this->waitee) && likely(!thd->check_killed()))
|
||||
mysql_cond_wait(&COND_wait_commit, &LOCK_wait_commit);
|
||||
if (!loc_waitee)
|
||||
{
|
||||
|
Reference in New Issue
Block a user