Skip to content

Commit f3b9497

Browse files
committed
encoder: Code cleanup
1 parent eaf020b commit f3b9497

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/simdjson_encoder.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -725,11 +725,11 @@ static void simdjson_encode_base64_object(smart_str *buf, const zval *val) {
725725

726726
static zend_result simdjson_encode_serializable_object(smart_str *buf, zval *val, simdjson_encoder *encoder) {
727727
zend_class_entry *ce = Z_OBJCE_P(val);
728+
zend_object *obj = Z_OBJ_P(val);
728729
zval retval;
729730
zend_result return_code;
730731

731732
#if PHP_VERSION_ID >= 80300
732-
zend_object *obj = Z_OBJ_P(val);
733733
uint32_t *guard = zend_get_recursion_guard(obj);
734734
ZEND_ASSERT(guard != NULL);
735735

@@ -752,7 +752,7 @@ static zend_result simdjson_encode_serializable_object(smart_str *buf, zval *val
752752

753753
zend_function *json_serialize_method = (zend_function*)zend_hash_find_ex_ptr(&ce->function_table, simdjson_json_serialize, 1);
754754
ZEND_ASSERT(json_serialize_method != NULL && "This should be guaranteed prior to calling this function");
755-
zend_call_known_instance_method_with_0_params(json_serialize_method, Z_OBJ_P(val), &retval);
755+
zend_call_known_instance_method_with_0_params(json_serialize_method, obj, &retval);
756756
/* An exception has occurred */
757757
if (Z_TYPE(retval) == IS_UNDEF) {
758758
#if PHP_VERSION_ID >= 80300
@@ -763,8 +763,7 @@ static zend_result simdjson_encode_serializable_object(smart_str *buf, zval *val
763763
return FAILURE;
764764
}
765765

766-
/* An exception has occurred */
767-
if (Z_TYPE(retval) == IS_OBJECT && Z_OBJ(retval) == Z_OBJ_P(val)) {
766+
if (Z_TYPE(retval) == IS_OBJECT && Z_OBJ(retval) == obj) {
768767
/* Handle the case where jsonSerialize does: return $this; by going straight to encode array */
769768
#if PHP_VERSION_ID >= 80300
770769
ZEND_GUARD_UNPROTECT_RECURSION(guard, JSON);

0 commit comments

Comments
 (0)