Skip to content

Commit

Permalink
frequency: rename var; use vec.truncate()
Browse files Browse the repository at this point in the history
  • Loading branch information
jqnatividad committed May 16, 2024
1 parent d9c01e1 commit 7c9f925
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/cmd/frequency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ impl Args {
if self.flag_lmt_threshold == 0 || self.flag_lmt_threshold >= unique_counts_len {
// check if the column has all unique values
// by checking if counts length is equal to ftable length
let pos_limit = self.flag_limit.unsigned_abs();
let abs_limit = self.flag_limit.unsigned_abs();
let unique_limited = if self.flag_limit > 0
&& self.flag_unq_limit != pos_limit
&& self.flag_unq_limit != abs_limit
&& self.flag_unq_limit > 0
&& unique_counts_len == ftab.len()
{
Expand All @@ -254,12 +254,12 @@ impl Args {

// check if we need to limit the number of values
if self.flag_limit > 0 {
counts = counts.into_iter().take(pos_limit).collect();
counts.truncate(abs_limit);
} else if self.flag_limit < 0 && !unique_limited {
// if limit is negative, only return values with an occurence count >= absolute
// value of the negative limit. We only do this if we haven't
// already unique limited the values
let count_limit = pos_limit as u64;
let count_limit = abs_limit as u64;
counts.retain(|(_, count)| *count >= count_limit);
}
}
Expand Down

0 comments on commit 7c9f925

Please sign in to comment.