summaryrefslogtreecommitdiff
path: root/numpy/core/src/npysort/npysort_heapsort.h
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/core/src/npysort/npysort_heapsort.h')
-rw-r--r--numpy/core/src/npysort/npysort_heapsort.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/numpy/core/src/npysort/npysort_heapsort.h b/numpy/core/src/npysort/npysort_heapsort.h
index 762d89b7b..16750b817 100644
--- a/numpy/core/src/npysort/npysort_heapsort.h
+++ b/numpy/core/src/npysort/npysort_heapsort.h
@@ -16,7 +16,7 @@
*/
template <typename Tag, typename type>
-NPY_INLINE NPY_NO_EXPORT
+inline NPY_NO_EXPORT
int heapsort_(type *start, npy_intp n)
{
type tmp, *a;
@@ -67,7 +67,7 @@ int heapsort_(type *start, npy_intp n)
}
template <typename Tag, typename type>
-NPY_INLINE NPY_NO_EXPORT
+inline NPY_NO_EXPORT
int aheapsort_(type *vv, npy_intp *tosort, npy_intp n)
{
type *v = vv;
@@ -123,11 +123,15 @@ int aheapsort_(type *vv, npy_intp *tosort, npy_intp n)
*/
template <typename Tag, typename type>
-NPY_INLINE NPY_NO_EXPORT
+inline NPY_NO_EXPORT
int string_heapsort_(type *start, npy_intp n, void *varr)
{
PyArrayObject *arr = (PyArrayObject *)varr;
size_t len = PyArray_ITEMSIZE(arr) / sizeof(type);
+ if (len == 0) {
+ return 0; /* no need for sorting if strings are empty */
+ }
+
type *tmp = (type *)malloc(PyArray_ITEMSIZE(arr));
type *a = (type *)start - len;
npy_intp i, j, l;
@@ -177,7 +181,7 @@ int string_heapsort_(type *start, npy_intp n, void *varr)
}
template <typename Tag, typename type>
-NPY_INLINE NPY_NO_EXPORT
+inline NPY_NO_EXPORT
int string_aheapsort_(type *vv, npy_intp *tosort, npy_intp n, void *varr)
{
type *v = vv;