Skip to content

Commit

Permalink
chore: minor optimization
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
  • Loading branch information
henryiii committed Mar 26, 2024
1 parent 38f8ead commit f3af194
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions include/pybind11/numpy.h
Original file line number Diff line number Diff line change
Expand Up @@ -698,10 +698,11 @@ class dtype : public object {
if (detail::npy_api::get().PyArray_RUNTIME_VERSION_ < 0x12) {
return detail::array_descriptor1_proxy(m_ptr)->names != nullptr;
}
if (num() < 0 || num() >= 2056) {
const auto *proxy = detail::array_descriptor2_proxy(m_ptr);
if (proxy->type_num < 0 || proxy->type_num >= 2056) {
return false;
}
return detail::array_descriptor2_proxy(m_ptr)->names != nullptr;
return proxy->names != nullptr;
}
#endif

Expand Down

0 comments on commit f3af194

Please sign in to comment.