Skip to content

Opts for portions of the code#13

Open
mdaiter wants to merge 2 commits intoPascalPons:masterfrom
mdaiter:opts
Open

Opts for portions of the code#13
mdaiter wants to merge 2 commits intoPascalPons:masterfrom
mdaiter:opts

Conversation

@mdaiter
Copy link

@mdaiter mdaiter commented May 2, 2019

Hey @PascalPons ,
Just had a few optimizations I'd like to commit. Most of these are minor that just caught my eye.
Thanks so much

return 0;
inline Position::position_t getNext() __attribute__((always_inline)) {
return size ? entries[--size].move : 0;
}
Copy link
Owner

Choose a reason for hiding this comment

The 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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http://www.cplusplus.com/articles/1AUq5Di1/
^This is standard. However, I understand if you don't want to include this for readability.

Copy link
Author

@mdaiter mdaiter May 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could even further optimise this to avoid your jump statement:

size -= static_cast<int>(size > 0);
return (size > 0) * entries[size].move;

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