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/protocol.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/protocol.cc')
-rw-r--r-- | sql/protocol.cc | 10 |
1 files changed, 5 insertions, 5 deletions
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<Item> *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); } |