Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PERF: add explicit noexcept qualifiers to fp_utils functions #4386

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions yt/utilities/lib/fp_utils.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,45 @@ cimport cython
cimport numpy as np


cdef inline np.int64_t imax(np.int64_t i0, np.int64_t i1) nogil:
cdef inline np.int64_t imax(np.int64_t i0, np.int64_t i1) noexcept nogil:
if i0 > i1: return i0
return i1

cdef inline np.float64_t fmax(np.float64_t f0, np.float64_t f1) nogil:
cdef inline np.float64_t fmax(np.float64_t f0, np.float64_t f1) noexcept nogil:
if f0 > f1: return f0
return f1

cdef inline np.int64_t imin(np.int64_t i0, np.int64_t i1) nogil:
cdef inline np.int64_t imin(np.int64_t i0, np.int64_t i1) noexcept nogil:
if i0 < i1: return i0
return i1

cdef inline np.float64_t fmin(np.float64_t f0, np.float64_t f1) nogil:
cdef inline np.float64_t fmin(np.float64_t f0, np.float64_t f1) noexcept nogil:
if f0 < f1: return f0
return f1

cdef inline np.float64_t fabs(np.float64_t f0) nogil:
cdef inline np.float64_t fabs(np.float64_t f0) noexcept nogil:
if f0 < 0.0: return -f0
return f0

cdef inline np.int64_t iclip(np.int64_t i, np.int64_t a, np.int64_t b) nogil:
cdef inline np.int64_t iclip(np.int64_t i, np.int64_t a, np.int64_t b) noexcept nogil:
if i < a: return a
if i > b: return b
return i

cdef inline np.int64_t i64clip(np.int64_t i, np.int64_t a, np.int64_t b) nogil:
cdef inline np.int64_t i64clip(np.int64_t i, np.int64_t a, np.int64_t b) noexcept nogil:
if i < a: return a
if i > b: return b
return i

cdef inline np.float64_t fclip(np.float64_t f,
np.float64_t a, np.float64_t b) nogil:
np.float64_t a, np.float64_t b) noexcept nogil:
return fmin(fmax(f, a), b)

cdef inline np.int64_t i64max(np.int64_t i0, np.int64_t i1) nogil:
cdef inline np.int64_t i64max(np.int64_t i0, np.int64_t i1) noexcept nogil:
if i0 > i1: return i0
return i1

cdef inline np.int64_t i64min(np.int64_t i0, np.int64_t i1) nogil:
cdef inline np.int64_t i64min(np.int64_t i0, np.int64_t i1) noexcept nogil:
if i0 < i1: return i0
return i1

Expand Down