Skip to content

Commit

Permalink
consolidate duplicate conditions in TextReader (#4530)
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb authored Aug 20, 2021
1 parent 981853b commit a926d4f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions include/LightGBM/utils/text_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down

0 comments on commit a926d4f

Please sign in to comment.