Skip to content

[CHORE] Remove use of inclusive ranges in for loops #204

@ptsouchlos

Description

@ptsouchlos

It seems there are some performance implications when using ..= in for loops. Our use case may be minor in byte-knight, but it's something we can fix to potentially help performance. I should also avoid using ..= in the future as well.

See:

rg output:

 rg "\..="
tools\hce-tuner\src\tuner.rs
41:        for epoch in 1..=self.max_epochs {

Makefile
12:     NAME := $(shell powershell -Command "(Get-Content Cargo.toml | Select-String '^name =').Line -replace '.*= ', '' -replace '\"', ''")
13:     VERSION := $(shell powershell -Command "(Get-Content Cargo.toml | Select-String '^version =').Line -replace '.*= ', '' -replace '\"', ''")

engine\src\history_table.rs
67:            for rank in (0..=NumberOf::RANKS - 1).rev() {

chess\src\side.rs
104:        for char in ('a'..='z').filter(|val| *val != 'w' && *val != 'b') {

chess\src\file.rs
153:        for c in 'i'..='z' {
169:        for i in 8..=u8::MAX {

chess\src\board.rs
821:        for rank in (Rank::R3 as u8)..=(Rank::R6 as u8) {
822:            for file in (File::A as u8)..=(File::H as u8) {

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions