-
Notifications
You must be signed in to change notification settings - Fork 60
Opts for portions of the code #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| CMAKE_MINIMUM_REQUIRED(VERSION 2.6) | ||
| PROJECT(CONNECT4) | ||
| SET(CONNECT4_VERSION_MAJOR 0) | ||
| SET(CONNECT4_VERSION_MINOR 9) | ||
|
|
||
| SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11 -W -Wall -O3 -DNDEBUG") | ||
|
|
||
| ADD_LIBRARY(c4solver_dependencies STATIC | ||
| Solver.cpp | ||
| Solver.hpp | ||
| Position.hpp | ||
| TranspositionTable.hpp | ||
| OpeningBook.hpp | ||
| MoveSorter.hpp) | ||
|
|
||
| ADD_EXECUTABLE(c4solver | ||
| main.cpp) | ||
|
|
||
| ADD_EXECUTABLE(c4generator | ||
| generator.cpp) | ||
|
|
||
| TARGET_LINK_LIBRARIES(c4solver c4solver_dependencies) | ||
| TARGET_LINK_LIBRARIES(c4generator c4solver_dependencies) | ||
|
|
||
| INSTALL(TARGETS c4solver_dependencies DESTINATION lib) | ||
| INSTALL(TARGETS c4generator DESTINATION bin) | ||
| INSTALL(TARGETS c4solver DESTINATION bin) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,7 +42,7 @@ class MoveSorter { | |
| * Add a move in the container with its score. | ||
| * You cannot add more than Position::WIDTH moves | ||
| */ | ||
| void add(Position::position_t move, int score) { | ||
| void add(const Position::position_t move, const int score) { | ||
| int pos = size++; | ||
| for(; pos && entries[pos - 1].score > score; --pos) entries[pos] = entries[pos - 1]; | ||
| entries[pos].move = move; | ||
|
|
@@ -54,11 +54,8 @@ class MoveSorter { | |
| * @return next remaining move with max score and remove it from the container. | ||
| * If no more move is available return 0 | ||
| */ | ||
| Position::position_t getNext() { | ||
| if(size) | ||
| return entries[--size].move; | ||
| else | ||
| return 0; | ||
| inline Position::position_t getNext() __attribute__((always_inline)) { | ||
| return size ? entries[--size].move : 0; | ||
| } | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer avoiding non standard C++ code. moreover any good C++ compiler will almost certainly inline this code without having to force it.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. http://www.cplusplus.com/articles/1AUq5Di1/
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could even further optimise this to avoid your jump statement: |
||
|
|
||
| /** | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.