Skip to content

Conversation

@gvreuls
Copy link
Contributor

@gvreuls gvreuls commented Mar 18, 2021

This changes the pop_lsb() signature from Square pop_lsb(Bitboard*) to Square pop_lsb(Bitboard&).

Just some refactoring, feel free to close.

No functional change.

This patch passed a non-regression STC test:
LLR: 2.93 (-2.94,2.94) {-1.25,0.25}
Total: 21280 W: 1928 L: 1847 D: 17505
Ptnml(0-2): 71, 1427, 7558, 1518, 66
https://tests.stockfishchess.org/tests/view/6053a1e22433018de7a38e2f

This changes the pop_lsb() signature from Square pop_lsb(Bitboard*) to
Square pop_lsb(Bitboard&).

No functional change.
@BM123499
Copy link
Contributor

BM123499 commented Mar 18, 2021

You also need to test non-regression on LTC, even though I don't think it's necessary.
In my opinion, I believe it's best to leave the way it is, because it's kind of warning that the Bitboard will be changed. But I'm not against this change.

@gvreuls
Copy link
Contributor Author

gvreuls commented Mar 18, 2021

@BM123499 I think using pointers where references will do is ugly and error-prone, but I don't want to revive the reference-vs-pointer discussion here.

I was saving this for a "Small cleanups" PR where usually no regression tests are run at all, but I was getting tired of waiting (and rebasing) so I made this PR. I'll run an LTC test if people think it's required, but I personally think it's a waste of resources.

@snicolet
Copy link
Member

I have compiled this patch, calculated the md5 hash of the executable binary and compared it to the md5 hash of master: they are the same, so the compiled binaries are the same at least for my compiler (gcc-10 on Mac). So yes, LTC is unnecessary in that case :-)

Patch looks good to me.

@BM123499
Copy link
Contributor

@gvreuls I understand your point of view, but I believe that the absence of signally that the value will be change inside another function has more change of a new dev misread what is going to happen.
Stockfish is a international code, we have a lot of code style here, so I believe that both ways to write is valid. We learn on different ways how to code and none is wrong.
So if most people are aligned with your way of reading the code, then let's change. I'm just remarking my point of view.

@gvreuls
Copy link
Contributor Author

gvreuls commented Mar 18, 2021

@BM123499 I think most C++ programmers expect that a Bitboard& function argument will be modified by the function, if it won't be modified they'd expect a const Bitboard& signature (or in case of bitboards a simple pass by value Bitboard) instead.

I appreciate and understand your point of view, don't worry. I think it's related to what code you read/write most often, C or C++.

@Sopel97
Copy link
Member

Sopel97 commented Mar 18, 2021

Passing a pointer also doesn't tell the whole picture on the callsite, for all we know it could be a const Bitboard*. I think this is a good change. The name of the function should reflect whether it modifies any arguments; pop_* is enough to signify that imo.

@snicolet snicolet closed this in ec42154 Mar 19, 2021
@snicolet
Copy link
Member

Merged via ec42154, thanks! :-)

@snicolet snicolet added the to be merged Will be merged shortly label Mar 19, 2021
MichaelB7 pushed a commit to MichaelB7/Stockfish that referenced this pull request Mar 20, 2021
This patch changes the pop_lsb() signature from Square pop_lsb(Bitboard*) to
Square pop_lsb(Bitboard&). This is more idomatic for C++ style signatures.

Passed a non-regression STC test:
LLR: 2.93 (-2.94,2.94) {-1.25,0.25}
Total: 21280 W: 1928 L: 1847 D: 17505
Ptnml(0-2): 71, 1427, 7558, 1518, 66
https://tests.stockfishchess.org/tests/view/6053a1e22433018de7a38e2f

We have verified that the generated binary is identical on gcc-10.

Closes official-stockfish#3404

No functional change.
joergoster pushed a commit to joergoster/Stockfish-old that referenced this pull request May 20, 2021
This patch changes the pop_lsb() signature from Square pop_lsb(Bitboard*) to
Square pop_lsb(Bitboard&). This is more idomatic for C++ style signatures.

Passed a non-regression STC test:
LLR: 2.93 (-2.94,2.94) {-1.25,0.25}
Total: 21280 W: 1928 L: 1847 D: 17505
Ptnml(0-2): 71, 1427, 7558, 1518, 66
https://tests.stockfishchess.org/tests/view/6053a1e22433018de7a38e2f

We have verified that the generated binary is identical on gcc-10.

Closes official-stockfish/Stockfish#3404

No functional change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

to be merged Will be merged shortly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants