aboutsummaryrefslogtreecommitdiff
path: root/src/cube_portable.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-05-25 11:50:16 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-05-25 11:50:16 +0200
commit43020af69d6932c7af0bc53b59c492775835a14e (patch)
treebf6d07a6ff2b5f37734fb1d1311a7468ad5acce9 /src/cube_portable.h
parent0ebba869512abc8e37e461e7587f686fe7c91c6c (diff)
downloadnissy-core-43020af69d6932c7af0bc53b59c492775835a14e.tar.gz
nissy-core-43020af69d6932c7af0bc53b59c492775835a14e.zip
Small performance improvement in h48 coordinate / transform
Diffstat (limited to 'src/cube_portable.h')
-rw-r--r--src/cube_portable.h52
1 files changed, 44 insertions, 8 deletions
diff --git a/src/cube_portable.h b/src/cube_portable.h
index e72c169..d62661a 100644
--- a/src/cube_portable.h
+++ b/src/cube_portable.h
@@ -11,6 +11,10 @@ _static cube_t fasttocube(cube_fast_t);
11_static_inline bool equal_fast(cube_fast_t, cube_fast_t); 11_static_inline bool equal_fast(cube_fast_t, cube_fast_t);
12_static_inline bool issolved_fast(cube_fast_t); 12_static_inline bool issolved_fast(cube_fast_t);
13_static_inline cube_fast_t invertco_fast(cube_fast_t); 13_static_inline cube_fast_t invertco_fast(cube_fast_t);
14_static_inline void compose_edges_inplace(cube_fast_t, cube_fast_t, cube_fast_t *);
15_static_inline void compose_corners_inplace(cube_fast_t, cube_fast_t, cube_fast_t *);
16_static_inline cube_fast_t compose_fast_edges(cube_fast_t, cube_fast_t);
17_static_inline cube_fast_t compose_fast_corners(cube_fast_t, cube_fast_t);
14_static_inline cube_fast_t compose_fast(cube_fast_t, cube_fast_t); 18_static_inline cube_fast_t compose_fast(cube_fast_t, cube_fast_t);
15 19
16_static_inline int64_t coord_fast_co(cube_fast_t); 20_static_inline int64_t coord_fast_co(cube_fast_t);
@@ -115,21 +119,24 @@ invertco_fast(cube_fast_t c)
115 return ret; 119 return ret;
116} 120}
117 121
118_static_inline cube_fast_t 122_static_inline void
119compose_fast(cube_fast_t c1, cube_fast_t c2) 123compose_edges_inplace(cube_fast_t c1, cube_fast_t c2, cube_fast_t *ret)
120{ 124{
121 cube_fast_t ret; 125 uint8_t i, piece1, piece2, p, orien;
122 uint8_t i, piece1, piece2, p, orien, aux, auy;
123
124 ret = zero_fast;
125 126
126 for (i = 0; i < 12; i++) { 127 for (i = 0; i < 12; i++) {
127 piece2 = c2.edge[i]; 128 piece2 = c2.edge[i];
128 p = piece2 & _pbits; 129 p = piece2 & _pbits;
129 piece1 = c1.edge[p]; 130 piece1 = c1.edge[p];
130 orien = (piece2 ^ piece1) & _eobit; 131 orien = (piece2 ^ piece1) & _eobit;
131 ret.edge[i] = (piece1 & _pbits) | orien; 132 ret->edge[i] = (piece1 & _pbits) | orien;
132 } 133 }
134}
135
136_static_inline void
137compose_corners_inplace(cube_fast_t c1, cube_fast_t c2, cube_fast_t *ret)
138{
139 uint8_t i, piece1, piece2, p, orien, aux, auy;
133 140
134 for (i = 0; i < 8; i++) { 141 for (i = 0; i < 8; i++) {
135 piece2 = c2.corner[i]; 142 piece2 = c2.corner[i];
@@ -138,8 +145,37 @@ compose_fast(cube_fast_t c1, cube_fast_t c2)
138 aux = (piece2 & _cobits) + (piece1 & _cobits); 145 aux = (piece2 & _cobits) + (piece1 & _cobits);
139 auy = (aux + _ctwist_cw) >> 2U; 146 auy = (aux + _ctwist_cw) >> 2U;
140 orien = (aux + auy) & _cobits2; 147 orien = (aux + auy) & _cobits2;
141 ret.corner[i] = (piece1 & _pbits) | orien; 148 ret->corner[i] = (piece1 & _pbits) | orien;
142 } 149 }
150}
151
152_static_inline cube_fast_t
153compose_fast_edges(cube_fast_t c1, cube_fast_t c2)
154{
155 cube_fast_t ret = zero_fast;
156
157 compose_edges_inplace(c1, c2, &ret);
158
159 return ret;
160}
161
162_static_inline cube_fast_t
163compose_fast_corners(cube_fast_t c1, cube_fast_t c2)
164{
165 cube_fast_t ret = zero_fast;
166
167 compose_corners_inplace(c1, c2, &ret);
168
169 return ret;
170}
171
172_static_inline cube_fast_t
173compose_fast(cube_fast_t c1, cube_fast_t c2)
174{
175 cube_fast_t ret = zero_fast;
176
177 compose_edges_inplace(c1, c2, &ret);
178 compose_corners_inplace(c1, c2, &ret);
143 179
144 return ret; 180 return ret;
145} 181}

Generated with cgit - Back to sebastiano.tronto.net