From 30ebc3ee9efcab635b1f3e14b9198a58ae93c233 Mon Sep 17 00:00:00 2001 From: Monty Date: Wed, 4 Apr 2018 12:16:12 +0300 Subject: 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() --- sql/protocol.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'sql/protocol.cc') diff --git a/sql/protocol.cc b/sql/protocol.cc index 771fade489b..d29d2fe853d 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -285,7 +285,7 @@ net_send_ok(THD *thd, DBUG_ASSERT(store.length() <= MAX_PACKET_LENGTH); error= my_net_write(net, (const unsigned char*)store.ptr(), store.length()); - if (!error && (!skip_flush || is_eof)) + if (likely(!error) && (!skip_flush || is_eof)) error= net_flush(net); thd->server_status&= ~SERVER_SESSION_STATE_CHANGED; @@ -349,7 +349,7 @@ net_send_eof(THD *thd, uint server_status, uint statement_warn_count) { thd->get_stmt_da()->set_overwrite_status(true); error= write_eof_packet(thd, net, server_status, statement_warn_count); - if (!error) + if (likely(!error)) error= net_flush(net); thd->get_stmt_da()->set_overwrite_status(false); DBUG_PRINT("info", ("EOF sent, so no more error sending allowed")); @@ -393,7 +393,7 @@ static bool write_eof_packet(THD *thd, NET *net, because if 'is_fatal_error' is set the server is not going to execute other queries (see the if test in dispatch_command / COM_QUERY) */ - if (thd->is_fatal_error) + if (unlikely(thd->is_fatal_error)) server_status&= ~SERVER_MORE_RESULTS_EXISTS; int2store(buff + 3, server_status); error= my_net_write(net, buff, 5); @@ -590,7 +590,7 @@ void Protocol::end_statement() thd->get_stmt_da()->skip_flush()); break; } - if (!error) + if (likely(!error)) thd->get_stmt_da()->set_is_sent(true); DBUG_VOID_RETURN; } @@ -990,7 +990,7 @@ bool Protocol::send_result_set_row(List *row_items) DBUG_RETURN(TRUE); } /* Item::send() may generate an error. If so, abort the loop. */ - if (thd->is_error()) + if (unlikely(thd->is_error())) DBUG_RETURN(TRUE); } -- cgit v1.2.1