Skip to content
Permalink
Browse files

Avoid too much overhead in layout_init (#6716)

* Avoid initializing primitive fields in layout_init

* Avoid initializing string/bytes/message fields in layout_init

* Lazily create map when needed

* Lazily create repeated fields

* Change layout_init to only do memcpy

* Fix test for php-7.0

* Fix conformance test where default value of string/message map is not encoded

* Fix test for zts

* Clean up

* Fix comments
  • Loading branch information...
TeBoring committed Oct 29, 2019
1 parent 3fa17ca commit c53e5b8e11659528150737f285e5c171b0f159b2
@@ -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
@@ -259,6 +259,19 @@ void repeated_field_push_native(RepeatedField *intern, void *value) {
}
}

void repeated_field_ensure_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) {

0 comments on commit c53e5b8

Please sign in to comment.
You can’t perform that action at this time.