Skip to content

Commit

Permalink
refactor: Eliminate waste in checking whether there are isolated suits.
Browse files Browse the repository at this point in the history
  • Loading branch information
Apricot-S committed Sep 24, 2024
1 parent 6fa8add commit 70addd9
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/standard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,7 @@ fn calculate_replacement_number_inner(
// A tile that is held in a quantity of four cannot become a pair.
num_gulipai -= four_tiles_gulipai.count_ones() as u8;

let num_four_tiles_gulipai_shupai =
four_tiles_gulipai[0..27].count_ones() as u8;

if (has_jiangpai || num_duizi != 0) && num_four_tiles_gulipai_shupai > 0 {
if (has_jiangpai || num_duizi != 0) && four_tiles_gulipai[0..27].any() {
// One of the isolated suits can become a sequence candidate.
num_gulipai += 1;
}
Expand Down Expand Up @@ -557,10 +554,7 @@ fn calculate_replacement_number_inner_3_player(
// A tile that is held in a quantity of four cannot become a pair.
num_gulipai -= four_tiles_gulipai.count_ones() as u8;

let num_four_tiles_gulipai_shupai =
four_tiles_gulipai[9..27].count_ones() as u8;

if (has_jiangpai || num_duizi != 0) && num_four_tiles_gulipai_shupai > 0 {
if (has_jiangpai || num_duizi != 0) && four_tiles_gulipai[9..27].any() {
// One of the isolated suits can become a sequence candidate.
num_gulipai += 1;
}
Expand Down

0 comments on commit 70addd9

Please sign in to comment.