Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid too much overhead in layout_init #6716

Merged
merged 10 commits into from Oct 29, 2019
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -139,6 +139,8 @@ composer.lock
php/tests/generated/
php/tests/old_protoc
php/tests/protobuf/
php/tests/core
php/tests/vgcore*
php/ext/google/protobuf/.libs/
php/ext/google/protobuf/Makefile.fragments
php/ext/google/protobuf/Makefile.global
Expand Down
13 changes: 13 additions & 0 deletions php/ext/google/protobuf/array.c
Expand Up @@ -259,6 +259,19 @@ void repeated_field_push_native(RepeatedField *intern, void *value) {
}
}

void repeated_field_insure_created(
const upb_fielddef *field,
CACHED_VALUE *repeated_field PHP_PROTO_TSRMLS_DC) {
if (ZVAL_IS_NULL(CACHED_PTR_TO_ZVAL_PTR(repeated_field))) {
zval_ptr_dtor(repeated_field);
#if PHP_MAJOR_VERSION < 7
MAKE_STD_ZVAL(CACHED_PTR_TO_ZVAL_PTR(repeated_field));
#endif
repeated_field_create_with_field(repeated_field_type, field,
repeated_field PHP_PROTO_TSRMLS_CC);
}
}

void repeated_field_create_with_field(
zend_class_entry *ce, const upb_fielddef *field,
CACHED_VALUE *repeated_field PHP_PROTO_TSRMLS_DC) {
Expand Down