Skip to content

Commit 93169cc

Browse files
committed
Small reduction in code complexity.
1 parent f128f1b commit 93169cc

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

include/pybind11/detail/smart_holder_type_casters.h

+2-4
Original file line numberDiff line numberDiff line change
@@ -422,11 +422,9 @@ struct smart_holder_type_caster_load {
422422
pybind11_fail("smart_holder_type_casters loaded_as_shared_ptr failure: "
423423
"load_impl.loaded_v_h.inst == sptsls_ptr->self");
424424
}
425-
return std::shared_ptr<T>(
426-
type_raw_ptr,
427-
shared_ptr_trampoline_self_life_support(load_impl.loaded_v_h.inst));
428425
}
429-
if (!pybindit::memory::type_has_shared_from_this(type_raw_ptr)) {
426+
if (sptsls_ptr != nullptr
427+
|| !pybindit::memory::type_has_shared_from_this(type_raw_ptr)) {
430428
return std::shared_ptr<T>(
431429
type_raw_ptr,
432430
shared_ptr_trampoline_self_life_support(load_impl.loaded_v_h.inst));

0 commit comments

Comments
 (0)