Skip to content

Commit 4fcbdea

Browse files
committed
ext/pdo: Turn lazy_object_ref into a zend_object* from a zval
This saves 8 bytes
1 parent 9054a8f commit 4fcbdea

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

ext/pdo/pdo_dbh.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -659,8 +659,6 @@ PHP_METHOD(PDO, prepare)
659659
/* give it a reference to me */
660660
GC_ADDREF(&dbh_obj->std);
661661
stmt->database_object_handle = &dbh_obj->std;
662-
/* we haven't created a lazy object yet */
663-
ZVAL_UNDEF(&stmt->lazy_object_ref);
664662

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

12311227
if (dbh->methods->preparer(dbh, statement, stmt, NULL)) {
12321228
PDO_STMT_CLEAR_ERR();

ext/pdo/pdo_stmt.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,17 +206,17 @@ PDO_API void php_pdo_stmt_set_column_count(pdo_stmt_t *stmt, int new_count)
206206
stmt->column_count = new_count;
207207
}
208208

209-
static void get_lazy_object(pdo_stmt_t *stmt, zval *return_value) /* {{{ */
209+
static void pdo_get_lazy_object(pdo_stmt_t *stmt, zval *return_value) /* {{{ */
210210
{
211-
if (Z_ISUNDEF(stmt->lazy_object_ref)) {
211+
if (stmt->lazy_object_ref == NULL) {
212212
pdo_row_t *row = zend_object_alloc(sizeof(pdo_row_t), pdo_row_ce);
213213
row->stmt = stmt;
214214
zend_object_std_init(&row->std, pdo_row_ce);
215-
ZVAL_OBJ(&stmt->lazy_object_ref, &row->std);
215+
stmt->lazy_object_ref = &row->std;
216216
GC_ADDREF(&stmt->std);
217217
GC_DELREF(&row->std);
218218
}
219-
ZVAL_COPY(return_value, &stmt->lazy_object_ref);
219+
ZVAL_OBJ_COPY(return_value, stmt->lazy_object_ref);
220220
}
221221
/* }}} */
222222

@@ -685,7 +685,7 @@ static bool do_fetch(pdo_stmt_t *stmt, zval *return_value, enum pdo_fetch_type h
685685
}
686686

687687
if (how == PDO_FETCH_LAZY) {
688-
get_lazy_object(stmt, return_value);
688+
pdo_get_lazy_object(stmt, return_value);
689689
return true;
690690
}
691691

@@ -2373,7 +2373,7 @@ static void pdo_row_free_storage(zend_object *std)
23732373
{
23742374
pdo_row_t *row = php_pdo_row_fetch_object(std);
23752375
if (row->stmt) {
2376-
ZVAL_UNDEF(&row->stmt->lazy_object_ref);
2376+
row->stmt->lazy_object_ref = NULL;
23772377
OBJ_RELEASE(&row->stmt->std);
23782378
}
23792379
}

ext/pdo/php_pdo_driver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ struct _pdo_stmt_t {
609609

610610
/* for lazy fetches, we always return the same lazy object handle.
611611
* Let's keep it here. */
612-
zval lazy_object_ref;
612+
zend_object *lazy_object_ref;
613613

614614
pdo_dbh_t *dbh;
615615
/* we want to keep the dbh alive while we live, so we own a reference */

0 commit comments

Comments
 (0)