Skip to content

Commit

Permalink
build: Fix build warnings
Browse files Browse the repository at this point in the history
Level 15 Debug self play test result:
118503ms/117685ms = 1.007
Reduce 0.7% performance.
  • Loading branch information
calcitem committed Jan 11, 2025
1 parent edf30d8 commit 068fef2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
10 changes: 8 additions & 2 deletions src/hashmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ class HashMap
hashTable = new HashNode<K, V>[hashSize];
#endif // ALIGNED_LARGE_PAGES

memset(hashTable, 0, sizeof(HashNode<K, V>) * hashSize);
for (size_t i = 0; i < hashSize; i++) {
hashTable[i].~HashNode<K, V>();
new (&hashTable[i]) HashNode<K, V>();
}
#else // DISABLE_HASHBUCKET
// create the key table as an array of key buckets
hashTable = new HashBucket<K, V>[hashSize];
Expand Down Expand Up @@ -151,7 +154,10 @@ class HashMap
void clear() const
{
#ifdef DISABLE_HASHBUCKET
memset(hashTable, 0, sizeof(HashNode<K, V>) * hashSize);
for (size_t i = 0; i < hashSize; i++) {
hashTable[i].~HashNode<K, V>();
new (&hashTable[i]) HashNode<K, V>();
}
#else // DISABLE_HASHBUCKET
for (size_t i = 0; i < hashSize; i++) {
(hashTable[i]).clear();
Expand Down
15 changes: 8 additions & 7 deletions src/position.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// position.cpp

#include <algorithm>
#include <iomanip>
#include <sstream>
#include <string> // std::string, std::stoi

#include "search_engine.h"
#include "mills.h"
#include "position.h"
#include "thread.h"
#include "search_engine.h"

#include <algorithm>
#include <cstring>
#include <iomanip>
#include <sstream>
#include <string>

using std::string;
using std::vector;
Expand Down Expand Up @@ -550,7 +551,7 @@ void Position::do_move(Move m)

void Position::undo_move(Sanmill::Stack<Position> &ss)
{
memcpy(this, ss.top(), sizeof(Position));
*this = *ss.top();
ss.pop();
}

Expand Down
3 changes: 1 addition & 2 deletions src/ui/qt/game_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,7 @@ void Game::updateTips()
recordGameOverReason();

scoreStr = "Score " + to_string(score[WHITE]) + " : " +
to_string(score[BLACK]) + ", Draw " +
to_string(score[DRAW]);
to_string(score[BLACK]) + ", Draw " + to_string(score[DRAW]);

switch (p.winner) {
case WHITE:
Expand Down

0 comments on commit 068fef2

Please sign in to comment.