ext/pdo: Convert _pdo_dbh_t query_stmt_zval to a zend_object pointer (#17742)

This saves 8 bytes
This commit is contained in:
Gina Peter Banyard 2025-02-08 19:27:51 +00:00 committed by GitHub
parent bff0ec82a6
commit 5333afa607
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 4 deletions

View file

@ -1248,7 +1248,7 @@ PHP_METHOD(PDO, query)
}
/* something broke */
dbh->query_stmt = stmt;
ZVAL_OBJ(&dbh->query_stmt_zval, Z_OBJ_P(return_value));
dbh->query_stmt_obj = Z_OBJ_P(return_value);
GC_DELREF(stmt->database_object_handle);
stmt->database_object_handle = NULL;
PDO_HANDLE_STMT_ERR();
@ -1468,7 +1468,8 @@ static void dbh_free(pdo_dbh_t *dbh, bool free_persistent)
int i;
if (dbh->query_stmt) {
zval_ptr_dtor(&dbh->query_stmt_zval);
OBJ_RELEASE(dbh->query_stmt_obj);
dbh->query_stmt_obj = NULL;
dbh->query_stmt = NULL;
}

View file

@ -499,7 +499,7 @@ struct _pdo_dbh_t {
* This will allow us to report the correct error message
* when PDO::query() fails */
pdo_stmt_t *query_stmt;
zval query_stmt_zval;
zend_object *query_stmt_obj;
/* defaults for fetches */
enum pdo_fetch_type default_fetch_type;

View file

@ -26,7 +26,8 @@ PDO_API void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt);
memcpy(dbh->error_code, PDO_ERR_NONE, sizeof(PDO_ERR_NONE)); \
if (dbh->query_stmt) { \
dbh->query_stmt = NULL; \
zval_ptr_dtor(&dbh->query_stmt_zval); \
OBJ_RELEASE(dbh->query_stmt_obj); \
dbh->query_stmt_obj = NULL; \
} \
} while (0)
#define PDO_STMT_CLEAR_ERR() do { \