Fix bug in macro. Shorten code.
This commit is contained in:
parent
f7b924801b
commit
dc4a1546eb
|
@ -53,9 +53,9 @@
|
||||||
|
|
||||||
#define INIT_EQUAL_CHECK_FUNC(val) \
|
#define INIT_EQUAL_CHECK_FUNC(val) \
|
||||||
int (*equal_check_func)(zval*, zval*); \
|
int (*equal_check_func)(zval*, zval*); \
|
||||||
if (Z_TYPE_P(element) == IS_LONG) \
|
if (Z_TYPE_P(val) == IS_LONG) \
|
||||||
equal_check_func = fast_equal_check_long; \
|
equal_check_func = fast_equal_check_long; \
|
||||||
else if (Z_TYPE_P(element) == IS_STRING) \
|
else if (Z_TYPE_P(val) == IS_STRING) \
|
||||||
equal_check_func = fast_equal_check_string; \
|
equal_check_func = fast_equal_check_string; \
|
||||||
else \
|
else \
|
||||||
equal_check_func = fast_equal_check_function;
|
equal_check_func = fast_equal_check_function;
|
||||||
|
@ -568,20 +568,13 @@ PHP_METHOD(Collection, init)
|
||||||
Z_PARAM_OPTIONAL
|
Z_PARAM_OPTIONAL
|
||||||
Z_PARAM_ZVAL(elements)
|
Z_PARAM_ZVAL(elements)
|
||||||
ZEND_PARSE_PARAMETERS_END();
|
ZEND_PARSE_PARAMETERS_END();
|
||||||
NEW_COLLECTION_OBJ(obj);
|
|
||||||
zval retval;
|
|
||||||
ZVAL_OBJ(&retval, obj);
|
|
||||||
if (elements) {
|
if (elements) {
|
||||||
ELEMENTS_VALIDATE(elements);
|
ELEMENTS_VALIDATE(elements);
|
||||||
COLLECTION_UPDATE(&retval, elements);
|
GC_ADDREF(Z_ARR_P(elements));
|
||||||
} else {
|
RETURN_NEW_COLLECTION(Z_ARRVAL_P(elements));
|
||||||
zval collection;
|
|
||||||
ZVAL_NEW_ARR(&collection);
|
|
||||||
zend_hash_init(Z_ARRVAL(collection), 0, NULL, ZVAL_PTR_DTOR, 0);
|
|
||||||
COLLECTION_UPDATE(&retval, &collection);
|
|
||||||
zval_ptr_dtor(&collection);
|
|
||||||
}
|
}
|
||||||
RETVAL_OBJ(obj);
|
ARRAY_NEW(collection, 0);
|
||||||
|
RETVAL_NEW_COLLECTION(collection);
|
||||||
}
|
}
|
||||||
|
|
||||||
PHP_METHOD(Collection, intersect)
|
PHP_METHOD(Collection, intersect)
|
||||||
|
|
|
@ -20,6 +20,11 @@ extern zend_module_entry collections_module_entry;
|
||||||
#define PHP_COLLECTIONS_API
|
#define PHP_COLLECTIONS_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if PHP_VERSION_ID < 70300
|
||||||
|
#define GC_ADDREF(p) ++GC_REFCOUNT(p)
|
||||||
|
#define GC_DELREF(p) --GC_REFCOUNT(p)
|
||||||
|
#endif
|
||||||
|
|
||||||
extern zend_string* collection_property_name;
|
extern zend_string* collection_property_name;
|
||||||
extern zend_string* pair_first_name;
|
extern zend_string* pair_first_name;
|
||||||
extern zend_string* pair_second_name;
|
extern zend_string* pair_second_name;
|
||||||
|
|
Reference in New Issue