summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Taylor <jtaylor.debian@googlemail.com>2014-02-15 14:15:30 +0100
committerJulian Taylor <jtaylor.debian@googlemail.com>2014-02-15 14:15:30 +0100
commitfd4bf676686ea20bb46797a665af36d974fc8415 (patch)
tree548cc79155070724fb8da9c263cab101f8daa4ef
parent86316b93e865bb06a5da14903e6f4c8330abb106 (diff)
downloadnumpy-fd4bf676686ea20bb46797a665af36d974fc8415.tar.gz
ENH: explicitly mark invalid index branch as unlikely
gcc already detects this as unlikely but it might profit other compilers.
-rw-r--r--numpy/core/src/multiarray/common.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/common.h b/numpy/core/src/multiarray/common.h
index 43c6dc386..ff1d4ec77 100644
--- a/numpy/core/src/multiarray/common.h
+++ b/numpy/core/src/multiarray/common.h
@@ -75,7 +75,7 @@ static NPY_INLINE int
check_and_adjust_index(npy_intp *index, npy_intp max_item, int axis)
{
/* Check that index is valid, taking into account negative indices */
- if ((*index < -max_item) || (*index >= max_item)) {
+ if (NPY_UNLIKELY((*index < -max_item) || (*index >= max_item))) {
/* Try to be as clear as possible about what went wrong. */
if (axis >= 0) {
PyErr_Format(PyExc_IndexError,