mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
MDEV-7942: InnoDB: abuse of UNIV_LIKELY()/UNIV_UNLIKELY()
UNIV_LIKELY()/UNIV_UNLIKELY() hints are supposed to improve branch prediction.
Currently, they're expected to work only if cond evaluates to TRUE or FALSE.
However there're a few conditions that may evaluate to different values, e.g.:
page/page0zip.cc: if (UNIV_LIKELY(c_stream->avail_in)) {
page/page0zip.cc: if (UNIV_LIKELY(c_stream->avail_in)) {
dict/dict0mem.cc: if (UNIV_LIKELY(i) && UNIV_UNLIKELY(!table->col_names)) {
Fixed these conditions so that they evaluate TRUE/FALSE.
This commit is contained in:
@@ -285,7 +285,7 @@ dict_mem_table_add_col(
|
||||
if (UNIV_UNLIKELY(table->n_def == table->n_cols)) {
|
||||
heap = table->heap;
|
||||
}
|
||||
if (UNIV_LIKELY(i) && UNIV_UNLIKELY(!table->col_names)) {
|
||||
if (UNIV_LIKELY(i != 0) && UNIV_UNLIKELY(table->col_names == NULL)) {
|
||||
/* All preceding column names are empty. */
|
||||
char* s = static_cast<char*>(
|
||||
mem_heap_zalloc(heap, table->n_def));
|
||||
|
||||
@@ -923,7 +923,7 @@ page_zip_compress_sec(
|
||||
rec - REC_N_NEW_EXTRA_BYTES
|
||||
- c_stream->next_in);
|
||||
|
||||
if (UNIV_LIKELY(c_stream->avail_in)) {
|
||||
if (UNIV_LIKELY(c_stream->avail_in != 0)) {
|
||||
UNIV_MEM_ASSERT_RW(c_stream->next_in,
|
||||
c_stream->avail_in);
|
||||
err = deflate(c_stream, Z_NO_FLUSH);
|
||||
@@ -1018,7 +1018,7 @@ page_zip_compress_clust_ext(
|
||||
|
||||
c_stream->avail_in = static_cast<uInt>(
|
||||
src - c_stream->next_in);
|
||||
if (UNIV_LIKELY(c_stream->avail_in)) {
|
||||
if (UNIV_LIKELY(c_stream->avail_in != 0)) {
|
||||
err = deflate(c_stream, Z_NO_FLUSH);
|
||||
if (UNIV_UNLIKELY(err != Z_OK)) {
|
||||
|
||||
|
||||
@@ -301,7 +301,7 @@ dict_mem_table_add_col(
|
||||
if (UNIV_UNLIKELY(table->n_def == table->n_cols)) {
|
||||
heap = table->heap;
|
||||
}
|
||||
if (UNIV_LIKELY(i) && UNIV_UNLIKELY(!table->col_names)) {
|
||||
if (UNIV_LIKELY(i != 0) && UNIV_UNLIKELY(table->col_names == NULL)) {
|
||||
/* All preceding column names are empty. */
|
||||
char* s = static_cast<char*>(
|
||||
mem_heap_zalloc(heap, table->n_def));
|
||||
|
||||
@@ -912,7 +912,7 @@ page_zip_compress_sec(
|
||||
rec - REC_N_NEW_EXTRA_BYTES
|
||||
- c_stream->next_in);
|
||||
|
||||
if (UNIV_LIKELY(c_stream->avail_in)) {
|
||||
if (UNIV_LIKELY(c_stream->avail_in != 0)) {
|
||||
UNIV_MEM_ASSERT_RW(c_stream->next_in,
|
||||
c_stream->avail_in);
|
||||
err = deflate(c_stream, Z_NO_FLUSH);
|
||||
@@ -1007,7 +1007,7 @@ page_zip_compress_clust_ext(
|
||||
|
||||
c_stream->avail_in = static_cast<uInt>(
|
||||
src - c_stream->next_in);
|
||||
if (UNIV_LIKELY(c_stream->avail_in)) {
|
||||
if (UNIV_LIKELY(c_stream->avail_in != 0)) {
|
||||
err = deflate(c_stream, Z_NO_FLUSH);
|
||||
if (UNIV_UNLIKELY(err != Z_OK)) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user