From f638ffef2c26236eab338d1f246317839bbdb631 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Sun, 28 Feb 2016 22:00:00 +0200 Subject: [PATCH] Convert if statements to switch case. --- sql/item_windowfunc.h | 1 - sql/sql_window.cc | 46 +++++++++++++++++++++++-------------------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/sql/item_windowfunc.h b/sql/item_windowfunc.h index e5769afd681..6277183ce58 100644 --- a/sql/item_windowfunc.h +++ b/sql/item_windowfunc.h @@ -372,5 +372,4 @@ public: }; - #endif /* ITEM_WINDOWFUNC_INCLUDED */ diff --git a/sql/sql_window.cc b/sql/sql_window.cc index 611fdb027a3..c7dcfb73341 100644 --- a/sql/sql_window.cc +++ b/sql/sql_window.cc @@ -886,28 +886,32 @@ bool JOIN::process_window_functions(List *curr_fields_list) item_win->setup_partition_border_check(thd); Item_sum::Sumfunctype type= item_win->window_func->sum_func(); - if (type == Item_sum::ROW_NUMBER_FUNC || - type == Item_sum::RANK_FUNC || - type == Item_sum::DENSE_RANK_FUNC) - { - /* - One-pass window function computation, walk through the rows and - assign values. - */ - if (compute_window_func_values(item_win, tbl, &info)) - is_error= true; + switch (type) { + case Item_sum::ROW_NUMBER_FUNC: + case Item_sum::RANK_FUNC: + case Item_sum::DENSE_RANK_FUNC: + { + /* + One-pass window function computation, walk through the rows and + assign values. + */ + if (compute_window_func_values(item_win, tbl, &info)) + is_error= true; + break; + } + case Item_sum::COUNT_FUNC: + { + /* + Frame-aware window function computation. It does one pass, but + uses three cursors -frame_start, current_row, and frame_end. + */ + if (compute_window_func_with_frames(item_win, tbl, &info)) + is_error= true; + break; + } + default: + DBUG_ASSERT(0); } - else if (type == Item_sum::COUNT_FUNC) - { - /* - Frame-aware window function computation. It does one pass, but - uses three cursors -frame_top, current_row, and frame_bottom. - */ - if (compute_window_func_with_frames(item_win, tbl, &info)) - is_error= true; - } - else - DBUG_ASSERT(0); item_win->set_read_value_from_result_field(); /* This calls filesort_free_buffers(): */