diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-10-04 12:01:41 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-10-04 12:01:41 +0200 |
| commit | 80b065f757240af7920862b3e09f32a6dc06d392 (patch) | |
| tree | c0223ba1f0a3254305f59637b3fb25bd58698cf8 /src/core/cube.h | |
| parent | fd111a1a51b8293f79db6284331af50824df92b9 (diff) | |
| download | nissy-core-80b065f757240af7920862b3e09f32a6dc06d392.tar.gz nissy-core-80b065f757240af7920862b3e09f32a6dc06d392.zip | |
Table-based transformations (will revert immediately)
This commit changes transformations to being based on a lookup
table intead of a big switch. This is something I had planned for a long
time and the code is nicer with this change. But unfortunately the performance
is noticeably worse, so I'll revert all these changes in the next commit.
I wanted to push this anyway so we can keep track of this.
Diffstat (limited to '')
| -rw-r--r-- | src/core/cube.h | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/core/cube.h b/src/core/cube.h index 2252a85..560d113 100644 --- a/src/core/cube.h +++ b/src/core/cube.h | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | STATIC cube_t solvecube(void); | 1 | STATIC cube_t solvecube(void); |
| 2 | STATIC cube_t cubefromarray(uint8_t [static 8], uint8_t [static 12]); | 2 | STATIC_INLINE cube_t cubefromarray_ce(uint8_t [static 8], uint8_t [static 12]); |
| 3 | STATIC_INLINE cube_t cubefromarray_single(uint8_t [static 20]); | ||
| 3 | STATIC bool isconsistent(cube_t); | 4 | STATIC bool isconsistent(cube_t); |
| 4 | STATIC bool issolvable(cube_t); | 5 | STATIC bool issolvable(cube_t); |
| 5 | STATIC bool issolved(cube_t); | 6 | STATIC bool issolved(cube_t); |
| @@ -14,15 +15,23 @@ solvedcube(void) | |||
| 14 | return SOLVED_CUBE; | 15 | return SOLVED_CUBE; |
| 15 | } | 16 | } |
| 16 | 17 | ||
| 17 | STATIC cube_t | 18 | STATIC_INLINE cube_t |
| 18 | cubefromarray(uint8_t c[static 8], uint8_t e[static 12]) | 19 | cubefromarray_ce(uint8_t c[static 8], uint8_t e[static 12]) |
| 19 | { | 20 | { |
| 20 | return STATIC_CUBE( | 21 | return cubefrompieces( |
| 21 | c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], | 22 | c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], |
| 22 | e[0], e[1], e[2], e[3], e[4], e[5], e[6], e[7], | 23 | e[0], e[1], e[2], e[3], e[4], e[5], e[6], e[7], |
| 23 | e[8], e[9], e[10], e[11]); | 24 | e[8], e[9], e[10], e[11]); |
| 24 | } | 25 | } |
| 25 | 26 | ||
| 27 | STATIC_INLINE cube_t | ||
| 28 | cubefromarray_single(uint8_t p[static 20]) | ||
| 29 | { | ||
| 30 | return cubefrompieces( | ||
| 31 | p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9], p[10], | ||
| 32 | p[11], p[12], p[13], p[14], p[15], p[16], p[17], p[18], p[19]); | ||
| 33 | } | ||
| 34 | |||
| 26 | STATIC bool | 35 | STATIC bool |
| 27 | isconsistent(cube_t cube) | 36 | isconsistent(cube_t cube) |
| 28 | { | 37 | { |
| @@ -178,5 +187,5 @@ getcube(int64_t ep, int64_t eo, int64_t cp, int64_t co) | |||
| 178 | for (i = 0; i < 8; i++) | 187 | for (i = 0; i < 8; i++) |
| 179 | carr[i] |= coarr[i] << COSHIFT; | 188 | carr[i] |= coarr[i] << COSHIFT; |
| 180 | 189 | ||
| 181 | return cubefromarray(carr, earr); | 190 | return cubefromarray_ce(carr, earr); |
| 182 | } | 191 | } |
