summaryrefslogtreecommitdiff
path: root/Zend/zend_operators.h
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2021-01-14 12:06:07 +0100
committerNikita Popov <nikita.ppv@gmail.com>2021-01-14 12:11:11 +0100
commit422d1665a2a744421b5911cbe8541370509bc4f5 (patch)
treefe173f4da139019d71a7bc88ffacfa8cd8f870dc /Zend/zend_operators.h
parent1b2aba285db488852844c2eac484d35569ec4442 (diff)
downloadphp-git-422d1665a2a744421b5911cbe8541370509bc4f5.tar.gz
Make convert_to_*_ex simple aliases of convert_to_*
Historically, the _ex variants separated the zval first, if a conversion was necessary. This distinction no longer makes sense since PHP 7. The only difference that was still left is that _ex checked whether the type is the same first, but the usage of these macros did not actually distinguish on whether such an inlined check is valuable or not in a given context. Also drop the unused convert_to_explicit_type macros.
Diffstat (limited to 'Zend/zend_operators.h')
-rw-r--r--Zend/zend_operators.h66
1 files changed, 8 insertions, 58 deletions
diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h
index d543b7b03c..1b02c75499 100644
--- a/Zend/zend_operators.h
+++ b/Zend/zend_operators.h
@@ -444,64 +444,14 @@ ZEND_API zend_long ZEND_FASTCALL zend_atol(const char *str, size_t str_len);
ZEND_API void ZEND_FASTCALL zend_locale_sprintf_double(zval *op ZEND_FILE_LINE_DC);
-#define convert_to_ex_master(pzv, lower_type, upper_type) \
- if (Z_TYPE_P(pzv)!=upper_type) { \
- convert_to_##lower_type(pzv); \
- }
-
-#define convert_to_explicit_type(pzv, type) \
- do { \
- switch (type) { \
- case IS_NULL: \
- convert_to_null(pzv); \
- break; \
- case IS_LONG: \
- convert_to_long(pzv); \
- break; \
- case IS_DOUBLE: \
- convert_to_double(pzv); \
- break; \
- case _IS_BOOL: \
- convert_to_boolean(pzv); \
- break; \
- case IS_ARRAY: \
- convert_to_array(pzv); \
- break; \
- case IS_OBJECT: \
- convert_to_object(pzv); \
- break; \
- case IS_STRING: \
- convert_to_string(pzv); \
- break; \
- default: \
- assert(0); \
- break; \
- } \
- } while (0);
-
-#define convert_to_explicit_type_ex(pzv, str_type) \
- if (Z_TYPE_P(pzv) != str_type) { \
- convert_to_explicit_type(pzv, str_type); \
- }
-
-#define convert_to_boolean_ex(pzv) do { \
- if (Z_TYPE_INFO_P(pzv) > IS_TRUE) { \
- convert_to_boolean(pzv); \
- } else if (Z_TYPE_INFO_P(pzv) < IS_FALSE) { \
- ZVAL_FALSE(pzv); \
- } \
- } while (0)
-#define convert_to_long_ex(pzv) convert_to_ex_master(pzv, long, IS_LONG)
-#define convert_to_double_ex(pzv) convert_to_ex_master(pzv, double, IS_DOUBLE)
-#define convert_to_string_ex(pzv) convert_to_ex_master(pzv, string, IS_STRING)
-#define convert_to_array_ex(pzv) convert_to_ex_master(pzv, array, IS_ARRAY)
-#define convert_to_object_ex(pzv) convert_to_ex_master(pzv, object, IS_OBJECT)
-#define convert_to_null_ex(pzv) convert_to_ex_master(pzv, null, IS_NULL)
-
-#define convert_scalar_to_number_ex(pzv) \
- if (Z_TYPE_P(pzv)!=IS_LONG && Z_TYPE_P(pzv)!=IS_DOUBLE) { \
- convert_scalar_to_number(pzv); \
- }
+#define convert_to_null_ex(zv) convert_to_null(zv)
+#define convert_to_boolean_ex(zv) convert_to_boolean(zv)
+#define convert_to_long_ex(zv) convert_to_long(zv)
+#define convert_to_double_ex(zv) convert_to_double(zv)
+#define convert_to_string_ex(zv) convert_to_string(zv)
+#define convert_to_array_ex(zv) convert_to_array(zv)
+#define convert_to_object_ex(zv) convert_to_object(zv)
+#define convert_scalar_to_number_ex(zv) convert_scalar_to_number(zv)
#if defined(ZEND_WIN32) && !defined(ZTS) && defined(_MSC_VER)
/* This performance improvement of tolower() on Windows gives 10-18% on bench.php */