From a926d4fe939118b6377455220e44ca9ded5b964e Mon Sep 17 00:00:00 2001 From: James Lamb Date: Fri, 20 Aug 2021 04:21:04 +0100 Subject: [PATCH] consolidate duplicate conditions in TextReader (#4530) --- include/LightGBM/utils/text_reader.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/LightGBM/utils/text_reader.h b/include/LightGBM/utils/text_reader.h index 638bb2683627..b6090b1ce9b2 100644 --- a/include/LightGBM/utils/text_reader.h +++ b/include/LightGBM/utils/text_reader.h @@ -198,8 +198,10 @@ class TextReader { [&filter_fun, &out_used_data_indices, this] (INDEX_T line_idx , const char* buffer, size_t size) { bool is_used = filter_fun(line_idx); - if (is_used) { out_used_data_indices->push_back(line_idx); } - if (is_used) { lines_.emplace_back(buffer, size); } + if (is_used) { + out_used_data_indices->push_back(line_idx); + lines_.emplace_back(buffer, size); + } }); return total_cnt; } @@ -213,8 +215,8 @@ class TextReader { &out_sampled_data] (INDEX_T line_idx, const char* buffer, size_t size) { bool is_used = filter_fun(line_idx); - if (is_used) { out_used_data_indices->push_back(line_idx); } if (is_used) { + out_used_data_indices->push_back(line_idx); if (cur_sample_cnt < sample_cnt) { out_sampled_data->emplace_back(buffer, size); ++cur_sample_cnt;