Skip to content

Make Board references constant where possible to improve clarity and avoid unnecessary copies#1166

Merged
lightvector merged 1 commit intolightvector:masterfrom
KvanTTT:const-references-and-avoid-unnecessary-copies
Mar 10, 2026
Merged

Make Board references constant where possible to improve clarity and avoid unnecessary copies#1166
lightvector merged 1 commit intolightvector:masterfrom
KvanTTT:const-references-and-avoid-unnecessary-copies

Conversation

@KvanTTT
Copy link
Contributor

@KvanTTT KvanTTT commented Mar 9, 2026

It looks like NNEvaluator::evaluate is a hot path and it would be nice to get rid of redundant copies. And it looks consistent because BoardHistory is also passed by const reference to evaluate.

@lightvector lightvector merged commit 938da7e into lightvector:master Mar 10, 2026
3 checks passed
@lightvector
Copy link
Owner

Thanks for the change! I had to check things over to verify that the board (and the hist) actually is const in places, but I think this looks good.

@KvanTTT
Copy link
Contributor Author

KvanTTT commented Mar 10, 2026

Thanks for the merging!

Actually, I've discovered much more unnecessary copies (using CLang-Tidy). The things should be treated carefully, because in some places copy syntax is used intentionally and it's incorrectly to use const references. But they should be emphasized explicitly.

Also, I've found a lot of places where push_back can be replaced with emplace_back and other performance problems. I will create a meta-issue to track them and will prepare merge requests step by step.

@KvanTTT KvanTTT deleted the const-references-and-avoid-unnecessary-copies branch March 10, 2026 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants