From 1c627c9ec0545640497c18b3a75deb6349b53a58 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Mon, 10 Jun 2019 22:18:11 +0200 Subject: [PATCH] pybind11_getbuffer: useless safe nullptr check (#1664) Alternative implementation for #1657: if we know that `obj` is never a `nullptr` [1], we should not `nullptr`-check it *after* already dereferencing it. [1] https://github.com/pybind/pybind11/pull/1657#issuecomment-452090058 --- include/pybind11/detail/class.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/pybind11/detail/class.h b/include/pybind11/detail/class.h index 6c88986f..b1916fcd 100644 --- a/include/pybind11/detail/class.h +++ b/include/pybind11/detail/class.h @@ -469,7 +469,7 @@ extern "C" inline int pybind11_getbuffer(PyObject *obj, Py_buffer *view, int fla if (tinfo && tinfo->get_buffer) break; } - if (view == nullptr || obj == nullptr || !tinfo || !tinfo->get_buffer) { + if (view == nullptr || !tinfo || !tinfo->get_buffer) { if (view) view->obj = nullptr; PyErr_SetString(PyExc_BufferError, "pybind11_getbuffer(): Internal error");