Skip to content

Commit 06b2d23

Browse files
authored
Merge pull request #1865 from hkBst/connect5-clippy-fixes
connect5: clippy fixes
2 parents 0057aa8 + 7f750f8 commit 06b2d23

File tree

1 file changed

+12
-25
lines changed

1 file changed

+12
-25
lines changed

examples/connect5.rs

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,8 @@ fn search(pos: &Pos, alpha: i32, beta: i32, depth: i32, _ply: i32) -> i32 {
558558
assert_ne!(bm, MOVE_NONE);
559559
assert!(bs >= -EVAL_INF && bs <= EVAL_INF);
560560

561-
if _ply == 0 { bm } else { bs } //best move at the root node, best score elsewhere
561+
// best move at the root node, best score elsewhere
562+
if _ply == 0 { bm } else { bs }
562563
}
563564

564565
/// Evaluation function: give different scores to different patterns after a fixed depth.
@@ -570,15 +571,11 @@ fn eval(pos: &Pos, _ply: i32) -> i32 {
570571
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
571572
{
572573
if check_x86_avx512_features() {
573-
unsafe {
574-
if check_patternlive4_avx512(pos, def) {
575-
return -4096;
576-
}
577-
}
578-
} else {
579-
if check_patternlive4(pos, def) {
574+
if unsafe { check_patternlive4_avx512(pos, def) } {
580575
return -4096;
581576
}
577+
} else if check_patternlive4(pos, def) {
578+
return -4096;
582579
}
583580
}
584581

@@ -593,15 +590,11 @@ fn eval(pos: &Pos, _ply: i32) -> i32 {
593590
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
594591
{
595592
if check_x86_avx512_features() {
596-
unsafe {
597-
if check_patternlive4_avx512(pos, atk) {
598-
return 2560;
599-
}
600-
}
601-
} else {
602-
if check_patternlive4(pos, atk) {
593+
if unsafe { check_patternlive4_avx512(pos, atk) } {
603594
return 2560;
604595
}
596+
} else if check_patternlive4(pos, atk) {
597+
return 2560;
605598
}
606599
}
607600

@@ -616,15 +609,11 @@ fn eval(pos: &Pos, _ply: i32) -> i32 {
616609
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
617610
{
618611
if check_x86_avx512_features() {
619-
unsafe {
620-
if check_patterndead4_avx512(pos, atk) > 0 {
621-
return 2560;
622-
}
623-
}
624-
} else {
625-
if check_patterndead4(pos, atk) > 0 {
612+
if unsafe { check_patterndead4_avx512(pos, atk) > 0 } {
626613
return 2560;
627614
}
615+
} else if check_patterndead4(pos, atk) > 0 {
616+
return 2560;
628617
}
629618
}
630619

@@ -909,9 +898,7 @@ fn pos_is_winner_avx512(pos: &Pos) -> bool {
909898
0b00_10_10_10_10_11_10_10_10_10_11_11_11_11_11_10];
910899
let mut count_match: i32 = 0;
911900

912-
for dir in 0..2 {
913-
// direction 0 and 1
914-
let mut board0 = board0org[dir];
901+
for mut board0 in board0org {
915902
let boardf = _mm512_and_si512(answer, board0);
916903
let temp_mask = _mm512_mask_cmpeq_epi16_mask(answer_mask[0], answer, boardf);
917904
count_match += _popcnt32(temp_mask as i32);

0 commit comments

Comments
 (0)