From 93169cc907c7d568ce71342f0fcf606191d95dcc Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Tue, 29 Jun 2021 16:00:27 -0700 Subject: [PATCH] Small reduction in code complexity. --- include/pybind11/detail/smart_holder_type_casters.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/pybind11/detail/smart_holder_type_casters.h b/include/pybind11/detail/smart_holder_type_casters.h index 0aaa4652a..797c152ce 100644 --- a/include/pybind11/detail/smart_holder_type_casters.h +++ b/include/pybind11/detail/smart_holder_type_casters.h @@ -422,11 +422,9 @@ struct smart_holder_type_caster_load { pybind11_fail("smart_holder_type_casters loaded_as_shared_ptr failure: " "load_impl.loaded_v_h.inst == sptsls_ptr->self"); } - return std::shared_ptr( - type_raw_ptr, - shared_ptr_trampoline_self_life_support(load_impl.loaded_v_h.inst)); } - if (!pybindit::memory::type_has_shared_from_this(type_raw_ptr)) { + if (sptsls_ptr != nullptr + || !pybindit::memory::type_has_shared_from_this(type_raw_ptr)) { return std::shared_ptr( type_raw_ptr, shared_ptr_trampoline_self_life_support(load_impl.loaded_v_h.inst));