Skip to content

Commit e005270

Browse files
R-Pelegmcostalba
authored andcommitted
Use constants arguments where possible
No functional changes.
1 parent 4f55ed1 commit e005270

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

src/evaluate.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -238,18 +238,18 @@ namespace {
238238
Score evaluate_pieces_of_color(const Position& pos, EvalInfo& ei, Score& mobility);
239239

240240
template<Color Us, bool Trace>
241-
Score evaluate_king(const Position& pos, EvalInfo& ei, Value margins[]);
241+
Score evaluate_king(const Position& pos, const EvalInfo& ei, Value margins[]);
242242

243243
template<Color Us, bool Trace>
244-
Score evaluate_threats(const Position& pos, EvalInfo& ei);
244+
Score evaluate_threats(const Position& pos, const EvalInfo& ei);
245245

246246
template<Color Us, bool Trace>
247-
Score evaluate_passed_pawns(const Position& pos, EvalInfo& ei);
247+
Score evaluate_passed_pawns(const Position& pos, const EvalInfo& ei);
248248

249249
template<Color Us>
250-
int evaluate_space(const Position& pos, EvalInfo& ei);
250+
int evaluate_space(const Position& pos, const EvalInfo& ei);
251251

252-
Score evaluate_unstoppable_pawns(const Position& pos, EvalInfo& ei);
252+
Score evaluate_unstoppable_pawns(const Position& pos, const EvalInfo& ei);
253253

254254
Value interpolate(const Score& v, Phase ph, ScaleFactor sf);
255255
Score apply_weight(Score v, Score w);
@@ -603,7 +603,7 @@ Value do_evaluate(const Position& pos, Value& margin) {
603603
// and the type of attacked one.
604604

605605
template<Color Us, bool Trace>
606-
Score evaluate_threats(const Position& pos, EvalInfo& ei) {
606+
Score evaluate_threats(const Position& pos, const EvalInfo& ei) {
607607

608608
const Color Them = (Us == WHITE ? BLACK : WHITE);
609609

@@ -674,7 +674,7 @@ Value do_evaluate(const Position& pos, Value& margin) {
674674
// evaluate_king<>() assigns bonuses and penalties to a king of a given color
675675

676676
template<Color Us, bool Trace>
677-
Score evaluate_king(const Position& pos, EvalInfo& ei, Value margins[]) {
677+
Score evaluate_king(const Position& pos, const EvalInfo& ei, Value margins[]) {
678678

679679
const Color Them = (Us == WHITE ? BLACK : WHITE);
680680

@@ -787,7 +787,7 @@ Value do_evaluate(const Position& pos, Value& margin) {
787787
// evaluate_passed_pawns<>() evaluates the passed pawns of the given color
788788

789789
template<Color Us, bool Trace>
790-
Score evaluate_passed_pawns(const Position& pos, EvalInfo& ei) {
790+
Score evaluate_passed_pawns(const Position& pos, const EvalInfo& ei) {
791791

792792
const Color Them = (Us == WHITE ? BLACK : WHITE);
793793

@@ -889,7 +889,7 @@ Value do_evaluate(const Position& pos, Value& margin) {
889889
// evaluate_unstoppable_pawns() evaluates the unstoppable passed pawns for both sides, this is quite
890890
// conservative and returns a winning score only when we are very sure that the pawn is winning.
891891

892-
Score evaluate_unstoppable_pawns(const Position& pos, EvalInfo& ei) {
892+
Score evaluate_unstoppable_pawns(const Position& pos, const EvalInfo& ei) {
893893

894894
Bitboard b, b2, blockers, supporters, queeningPath, candidates;
895895
Square s, blockSq, queeningSquare;
@@ -1054,7 +1054,7 @@ Value do_evaluate(const Position& pos, Value& margin) {
10541054
// twice. Finally, the space bonus is scaled by a weight taken from the
10551055
// material hash table. The aim is to improve play on game opening.
10561056
template<Color Us>
1057-
int evaluate_space(const Position& pos, EvalInfo& ei) {
1057+
int evaluate_space(const Position& pos, const EvalInfo& ei) {
10581058

10591059
const Color Them = (Us == WHITE ? BLACK : WHITE);
10601060

src/thread.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ bool Thread::cutoff_occurred() const {
164164
// which are busy searching the split point at the top of slaves split point
165165
// stack (the "helpful master concept" in YBWC terminology).
166166

167-
bool Thread::is_available_to(Thread* master) const {
167+
bool Thread::is_available_to(const Thread* master) const {
168168

169169
if (searching)
170170
return false;
@@ -238,7 +238,7 @@ void ThreadPool::read_uci_options() {
238238
// slave_available() tries to find an idle thread which is available as a slave
239239
// for the thread 'master'.
240240

241-
Thread* ThreadPool::available_slave(Thread* master) const {
241+
Thread* ThreadPool::available_slave(const Thread* master) const {
242242

243243
for (const_iterator it = begin(); it != end(); ++it)
244244
if ((*it)->is_available_to(master))
@@ -258,7 +258,7 @@ Thread* ThreadPool::available_slave(Thread* master) const {
258258
// search() then split() returns.
259259

260260
template <bool Fake>
261-
void Thread::split(Position& pos, Stack* ss, Value alpha, Value beta, Value* bestValue,
261+
void Thread::split(Position& pos, const Stack* ss, Value alpha, Value beta, Value* bestValue,
262262
Move* bestMove, Depth depth, Move threatMove, int moveCount,
263263
MovePicker* movePicker, int nodeType, bool cutNode) {
264264

@@ -348,8 +348,8 @@ void Thread::split(Position& pos, Stack* ss, Value alpha, Value beta, Value* bes
348348
}
349349

350350
// Explicit template instantiations
351-
template void Thread::split<false>(Position&, Stack*, Value, Value, Value*, Move*, Depth, Move, int, MovePicker*, int, bool);
352-
template void Thread::split< true>(Position&, Stack*, Value, Value, Value*, Move*, Depth, Move, int, MovePicker*, int, bool);
351+
template void Thread::split<false>(Position&, const Stack*, Value, Value, Value*, Move*, Depth, Move, int, MovePicker*, int, bool);
352+
template void Thread::split< true>(Position&, const Stack*, Value, Value, Value*, Move*, Depth, Move, int, MovePicker*, int, bool);
353353

354354

355355
// wait_for_think_finished() waits for main thread to go to sleep then returns

src/thread.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ struct Thread : public ThreadBase {
114114
Thread();
115115
virtual void idle_loop();
116116
bool cutoff_occurred() const;
117-
bool is_available_to(Thread* master) const;
117+
bool is_available_to(const Thread* master) const;
118118

119119
template <bool Fake>
120-
void split(Position& pos, Search::Stack* ss, Value alpha, Value beta, Value* bestValue, Move* bestMove,
120+
void split(Position& pos, const Search::Stack* ss, Value alpha, Value beta, Value* bestValue, Move* bestMove,
121121
Depth depth, Move threatMove, int moveCount, MovePicker* movePicker, int nodeType, bool cutNode);
122122

123123
SplitPoint splitPoints[MAX_SPLITPOINTS_PER_THREAD];
@@ -160,7 +160,7 @@ struct ThreadPool : public std::vector<Thread*> {
160160

161161
MainThread* main() { return static_cast<MainThread*>((*this)[0]); }
162162
void read_uci_options();
163-
Thread* available_slave(Thread* master) const;
163+
Thread* available_slave(const Thread* master) const;
164164
void wait_for_think_finished();
165165
void start_thinking(const Position&, const Search::LimitsType&,
166166
const std::vector<Move>&, Search::StateStackPtr&);

0 commit comments

Comments
 (0)