Skip to content

Commit 5333afa

Browse files
authored
ext/pdo: Convert _pdo_dbh_t query_stmt_zval to a zend_object pointer (#17742)
This saves 8 bytes
1 parent bff0ec8 commit 5333afa

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

ext/pdo/pdo_dbh.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,7 +1248,7 @@ PHP_METHOD(PDO, query)
12481248
}
12491249
/* something broke */
12501250
dbh->query_stmt = stmt;
1251-
ZVAL_OBJ(&dbh->query_stmt_zval, Z_OBJ_P(return_value));
1251+
dbh->query_stmt_obj = Z_OBJ_P(return_value);
12521252
GC_DELREF(stmt->database_object_handle);
12531253
stmt->database_object_handle = NULL;
12541254
PDO_HANDLE_STMT_ERR();
@@ -1468,7 +1468,8 @@ static void dbh_free(pdo_dbh_t *dbh, bool free_persistent)
14681468
int i;
14691469

14701470
if (dbh->query_stmt) {
1471-
zval_ptr_dtor(&dbh->query_stmt_zval);
1471+
OBJ_RELEASE(dbh->query_stmt_obj);
1472+
dbh->query_stmt_obj = NULL;
14721473
dbh->query_stmt = NULL;
14731474
}
14741475

ext/pdo/php_pdo_driver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ struct _pdo_dbh_t {
499499
* This will allow us to report the correct error message
500500
* when PDO::query() fails */
501501
pdo_stmt_t *query_stmt;
502-
zval query_stmt_zval;
502+
zend_object *query_stmt_obj;
503503

504504
/* defaults for fetches */
505505
enum pdo_fetch_type default_fetch_type;

ext/pdo/php_pdo_error.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ PDO_API void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt);
2626
memcpy(dbh->error_code, PDO_ERR_NONE, sizeof(PDO_ERR_NONE)); \
2727
if (dbh->query_stmt) { \
2828
dbh->query_stmt = NULL; \
29-
zval_ptr_dtor(&dbh->query_stmt_zval); \
29+
OBJ_RELEASE(dbh->query_stmt_obj); \
30+
dbh->query_stmt_obj = NULL; \
3031
} \
3132
} while (0)
3233
#define PDO_STMT_CLEAR_ERR() do { \

0 commit comments

Comments
 (0)