Skip to content

Commit f109f04

Browse files
ndosschedunglas
authored andcommitted
perf: avoid redundant work in frankenphp_release_temporary_streams()
Persistent streams are of type le_pstream, not le_stream. Therefore, the persistent check will always be false. We can thus replace that check with an assertion. `zend_list_delete` removes the entry from the regular_list table, and calls `zend_resource_dtor` via the table destructor. When the refcount is 1, `zend_list_close` calls `zend_resource_dtor`, but keeps the entry in the table. Multiple calls to `zend_resource_dtor` have no effect: the destructor is only called once. Therefore, the `zend_list_close` operation is redundant because it is fully included in the work done by `zend_list_delete`.
1 parent d407dbd commit f109f04

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

frankenphp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ static void frankenphp_release_temporary_streams() {
121121
if (val->type == stream_type) {
122122
php_stream *stream = (php_stream *)val->ptr;
123123
if (stream != NULL && stream->ops == &php_stream_temp_ops &&
124-
!stream->is_persistent && stream->__exposed == 0 &&
124+
stream->__exposed == 0 &&
125125
GC_REFCOUNT(val) == 1) {
126-
zend_list_close(val);
126+
ZEND_ASSERT(!stream->is_persistent);
127127
zend_list_delete(val);
128128
}
129129
}

0 commit comments

Comments
 (0)