From: Jörg Breitbart Date: Tue, 9 Sep 2025 18:09:07 +0000 (+0200) Subject: some cleanup X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=36d7ff055e1aa424b51c47af8df62f97a21bcb40;p=thirdparty%2Fpsycopg.git some cleanup --- diff --git a/psycopg_c/psycopg_c/_psycopg/transform.pyx b/psycopg_c/psycopg_c/_psycopg/transform.pyx index 78b1579e4..1f8f0d3cc 100644 --- a/psycopg_c/psycopg_c/_psycopg/transform.pyx +++ b/psycopg_c/psycopg_c/_psycopg/transform.pyx @@ -443,39 +443,35 @@ cdef class Transformer: cdef object records = PyList_New(row1 - row0) cdef PyObject *loader # borrowed RowLoader - cdef tuple brecord row_loaders = self._row_loaders # avoid an incref/decref per item for row in range(row0, row1): - brecord = PyTuple_New(self._nfields) + record = PyTuple_New(self._nfields) for col in range(self._nfields): - loader = PyList_GET_ITEM(row_loaders, col) attval = &(ires.tuples[row][col]) if attval.len == -1: # NULL_LEN pyval = None - elif (loader).cloader is not None: - pyval = (loader).cloader.cload( - attval.value, attval.len) else: - b = PyMemoryView_FromObject( - ViewBuffer._from_buffer( - self._pgresult, - attval.value, attval.len)) - pyval = PyObject_CallFunctionObjArgs( - (loader).loadfunc, b, NULL) + loader = PyList_GET_ITEM(row_loaders, col) + if (loader).cloader is not None: + pyval = (loader).cloader.cload( + attval.value, attval.len) + else: + b = PyMemoryView_FromObject( + ViewBuffer._from_buffer( + self._pgresult, + attval.value, + attval.len + )) + pyval = PyObject_CallFunctionObjArgs( + (loader).loadfunc, b, NULL) Py_INCREF(pyval) - PyTuple_SET_ITEM(brecord, col, pyval) - Py_INCREF(brecord) - PyList_SET_ITEM(records, row - row0, brecord) - - if make_row is not tuple: - for i in range(row1 - row0): - brecord = PyList_GET_ITEM(records, i) + PyTuple_SET_ITEM(record, col, pyval) + if make_row is not tuple: record = PyObject_CallFunctionObjArgs( - make_row, brecord, NULL) - Py_INCREF(record) - PyList_SET_ITEM(records, i, record) - Py_DECREF(brecord) + make_row, record, NULL) + Py_INCREF(record) + PyList_SET_ITEM(records, row - row0, record) return records def load_row(self, int row, object make_row) -> Row: