Skip to content

Commit fc4f83c

Browse files
committed
Split BSON structure checks for legibility
1 parent fc928f5 commit fc4f83c

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/phongo_bson_encode.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,16 @@ static void php_phongo_bson_append_object(bson_t* bson, php_phongo_field_path* f
104104
}
105105

106106
if (Z_TYPE_P(object) == IS_OBJECT && instanceof_function(Z_OBJCE_P(object), php_phongo_type_ce)) {
107-
if (Z_TYPE_P(object) == IS_OBJECT && (instanceof_function(Z_OBJCE_P(object), php_phongo_document_ce) || instanceof_function(Z_OBJCE_P(object), php_phongo_packedarray_ce))) {
108-
if (instanceof_function(Z_OBJCE_P(object), php_phongo_document_ce)) {
109-
php_phongo_document_t* intern = Z_DOCUMENT_OBJ_P(object);
110-
bson_append_document(bson, key, key_len, intern->bson);
111-
} else {
112-
php_phongo_packedarray_t* intern = Z_PACKEDARRAY_OBJ_P(object);
113-
bson_append_array(bson, key, key_len, intern->bson);
114-
}
107+
if (instanceof_function(Z_OBJCE_P(object), php_phongo_document_ce)) {
108+
php_phongo_document_t* intern = Z_DOCUMENT_OBJ_P(object);
109+
bson_append_document(bson, key, key_len, intern->bson);
110+
111+
return;
112+
}
113+
114+
if (instanceof_function(Z_OBJCE_P(object), php_phongo_packedarray_ce)) {
115+
php_phongo_packedarray_t* intern = Z_PACKEDARRAY_OBJ_P(object);
116+
bson_append_array(bson, key, key_len, intern->bson);
115117

116118
return;
117119
}

0 commit comments

Comments
 (0)