File tree 1 file changed +5
-8
lines changed
numpy/core/src/multiarray 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -197,15 +197,12 @@ static NPY_INLINE int
197
197
npy_is_aligned (const void * p , const npy_uintp alignment )
198
198
{
199
199
/*
200
- * alignment is usually a power of two
201
- * the test is faster than a direct modulo
200
+ * Assumes alignment is a power of two, as required by the C standard.
201
+ * Assumes cast from pointer to uintp gives a sensible representation we
202
+ * can use bitwise & on (not required by C standard, but used by glibc).
203
+ * This test is faster than a direct modulo.
202
204
*/
203
- if (NPY_LIKELY ((alignment & (alignment - 1 )) == 0 )) {
204
- return ((npy_uintp )(p ) & ((alignment ) - 1 )) == 0 ;
205
- }
206
- else {
207
- return ((npy_uintp )(p ) % alignment ) == 0 ;
208
- }
205
+ return ((npy_uintp )(p ) & ((alignment ) - 1 )) == 0 ;
209
206
}
210
207
211
208
/* Get equivalent "uint" alignment given an itemsize, for use in copy code */
You can’t perform that action at this time.
0 commit comments