Chessnix (02) magical refactoring problem

I started this thread:

asking about why I have such a performance loss after a simple refactor.

For those of you who are curious I made a temporary release with the title “dont use this” of the chess program containing the source code for the fast en the slow (refactored) version.

  1. Compile for releasefast
  2. Run the program.
  3. In the terminal type “bench” which starts speed tests for 4 chess positions.
  4. See the enormous difference in “moves per second”.

In types.zig the refactored CastleType and Color (both 1 bit) can be found: from packed union to simple enum.

There are a lot of calls to the functions u() of CastleType and Color, where I would expect the “slow” version to be just to be as fast as the “fast” one.

I have no clue where to start digging.
Any help appreciated, because I don’t really like the packed union version.

1 Like

solved in the other thread.