diff options
author | Allan Haldane <allan.haldane@gmail.com> | 2018-09-26 21:06:03 -0400 |
---|---|---|
committer | Allan Haldane <allan.haldane@gmail.com> | 2018-09-27 15:43:54 -0400 |
commit | 12bd7c372ab5eeeff8bd2a46d765ccf28c6ce486 (patch) | |
tree | 43f5f8b822612857daaaaaa729ba63b51eb3bb81 | |
parent | 38af6ddb5896525b9553edd6c8c9817c7c3b1d21 (diff) | |
download | numpy-12bd7c372ab5eeeff8bd2a46d765ccf28c6ce486.tar.gz |
MAINT: remove unneeded test in npy_is_aligned
-rw-r--r-- | numpy/core/src/multiarray/common.h | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/numpy/core/src/multiarray/common.h b/numpy/core/src/multiarray/common.h index 12195ab15..2b8d3d3a4 100644 --- a/numpy/core/src/multiarray/common.h +++ b/numpy/core/src/multiarray/common.h @@ -197,15 +197,12 @@ static NPY_INLINE int npy_is_aligned(const void * p, const npy_uintp alignment) { /* - * alignment is usually a power of two - * the test is faster than a direct modulo + * Assumes alignment is a power of two, as required by the C standard. + * Assumes cast from pointer to uintp gives a sensible representation we + * can use bitwise & on (not required by C standard, but used by glibc). + * This test is faster than a direct modulo. */ - if (NPY_LIKELY((alignment & (alignment - 1)) == 0)) { - return ((npy_uintp)(p) & ((alignment) - 1)) == 0; - } - else { - return ((npy_uintp)(p) % alignment) == 0; - } + return ((npy_uintp)(p) & ((alignment) - 1)) == 0; } /* Get equivalent "uint" alignment given an itemsize, for use in copy code */ |