1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

ext/pdo: Turn lazy_object_ref into a zend_object* from a zval

This saves 8 bytes
This commit is contained in:
Gina Peter Banyard
2025-01-30 19:19:38 +00:00
parent 9054a8f214
commit 4fcbdea974
3 changed files with 7 additions and 11 deletions

View File

@@ -659,8 +659,6 @@ PHP_METHOD(PDO, prepare)
/* give it a reference to me */
GC_ADDREF(&dbh_obj->std);
stmt->database_object_handle = &dbh_obj->std;
/* we haven't created a lazy object yet */
ZVAL_UNDEF(&stmt->lazy_object_ref);
if (dbh->methods->preparer(dbh, statement, stmt, options)) {
if (Z_TYPE(ctor_args) == IS_ARRAY) {
@@ -1225,8 +1223,6 @@ PHP_METHOD(PDO, query)
/* give it a reference to me */
GC_ADDREF(&dbh_obj->std);
stmt->database_object_handle = &dbh_obj->std;
/* we haven't created a lazy object yet */
ZVAL_UNDEF(&stmt->lazy_object_ref);
if (dbh->methods->preparer(dbh, statement, stmt, NULL)) {
PDO_STMT_CLEAR_ERR();

View File

@@ -206,17 +206,17 @@ PDO_API void php_pdo_stmt_set_column_count(pdo_stmt_t *stmt, int new_count)
stmt->column_count = new_count;
}
static void get_lazy_object(pdo_stmt_t *stmt, zval *return_value) /* {{{ */
static void pdo_get_lazy_object(pdo_stmt_t *stmt, zval *return_value) /* {{{ */
{
if (Z_ISUNDEF(stmt->lazy_object_ref)) {
if (stmt->lazy_object_ref == NULL) {
pdo_row_t *row = zend_object_alloc(sizeof(pdo_row_t), pdo_row_ce);
row->stmt = stmt;
zend_object_std_init(&row->std, pdo_row_ce);
ZVAL_OBJ(&stmt->lazy_object_ref, &row->std);
stmt->lazy_object_ref = &row->std;
GC_ADDREF(&stmt->std);
GC_DELREF(&row->std);
}
ZVAL_COPY(return_value, &stmt->lazy_object_ref);
ZVAL_OBJ_COPY(return_value, stmt->lazy_object_ref);
}
/* }}} */
@@ -685,7 +685,7 @@ static bool do_fetch(pdo_stmt_t *stmt, zval *return_value, enum pdo_fetch_type h
}
if (how == PDO_FETCH_LAZY) {
get_lazy_object(stmt, return_value);
pdo_get_lazy_object(stmt, return_value);
return true;
}
@@ -2373,7 +2373,7 @@ static void pdo_row_free_storage(zend_object *std)
{
pdo_row_t *row = php_pdo_row_fetch_object(std);
if (row->stmt) {
ZVAL_UNDEF(&row->stmt->lazy_object_ref);
row->stmt->lazy_object_ref = NULL;
OBJ_RELEASE(&row->stmt->std);
}
}

View File

@@ -609,7 +609,7 @@ struct _pdo_stmt_t {
/* for lazy fetches, we always return the same lazy object handle.
* Let's keep it here. */
zval lazy_object_ref;
zend_object *lazy_object_ref;
pdo_dbh_t *dbh;
/* we want to keep the dbh alive while we live, so we own a reference */