8000 Inline gmp_unary_opl() as it was only used once · divinity76/php-src@2313a46 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2313a46

Browse files
committed
Inline gmp_unary_opl() as it was only used once
That use being gmp_popcount()
1 parent 9ee1265 commit 2313a46

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

ext/gmp/gmp.c

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ static void gmp_cmp(zval *return_value, zval *a_arg, zval *b_arg, bool is_operat
194194
* include parameter parsing.
195195
*/
196196
typedef void (*gmp_unary_op_t)(mpz_ptr, mpz_srcptr);
197-
typedef mp_bitcnt_t (*gmp_unary_opl_t)(mpz_srcptr);
198197

199198
typedef void (*gmp_unary_ui_op_t)(mpz_ptr, gmp_ulong);
200199

@@ -241,7 +240,6 @@ static void gmp_mpz_gcd_ui(mpz_ptr a, mpz_srcptr b, gmp_ulong c) {
241240

242241
/* Unary operations */
243242
#define gmp_unary_op(op) _gmp_unary_op(INTERNAL_FUNCTION_PARAM_PASSTHRU, op)
244-
#define gmp_unary_opl(op) _gmp_unary_opl(INTERNAL_FUNCTION_PARAM_PASSTHRU, op)
245243

246244
static void gmp_free_object_storage(zend_object *obj) /* {{{ */
247245
{
@@ -928,23 +926,6 @@ static inline void _gmp_unary_op(INTERNAL_FUNCTION_PARAMETERS, gmp_unary_op_t gm
928926
}
929927
/* }}} */
930928

931-
/* {{{ _gmp_unary_opl */
932-
static inline void _gmp_unary_opl(INTERNAL_FUNCTION_PARAMETERS, gmp_unary_opl_t gmp_op)
933-
{
934-
zval *a_arg;
935-
mpz_ptr gmpnum_a;
936-
gmp_temp_t temp_a;
937-
938-
ZEND_PARSE_PARAMETERS_START(1, 1)
939-
Z_PARAM_ZVAL(a_arg)
940-
ZEND_PARSE_PARAMETERS_END();
941-
942-
FETCH_GMP_ZVAL(gmpnum_a, a_arg, temp_a, 1);
943-
RETVAL_LONG(gmp_op(gmpnum_a));
944-
FREE_GMP_TEMP(temp_a);
945-
}
946-
/* }}} */
947-
948929
static bool gmp_verify_base(zend_long base, uint32_t arg_num)
949930
{
950931
if (base && (base < 2 || base > GMP_MAX_BASE)) {
@@ -1841,7 +1822,6 @@ ZEND_FUNCTION(gmp_cmp)
18411822
/* {{{ Gets the sign of the number */
18421823
ZEND_FUNCTION(gmp_sign)
18431824
{
1844-
/* Can't use gmp_unary_opl here, because mpz_sgn is a macro */
18451825
zval *a_arg;
18461826
mpz_ptr gmpnum_a;
18471827
gmp_temp_t temp_a;
@@ -2110,7 +2090,17 @@ ZEND_FUNCTION(gmp_testbit)
21102090
/* {{{ Calculates the population count of a */
21112091
ZEND_FUNCTION(gmp_popcount)
21122092
{
2113-
gmp_unary_opl(mpz_popcount);
2093+
zval *a_arg;
2094+
mpz_ptr gmpnum_a;
2095+
gmp_temp_t temp_a;
2096+
2097+
ZEND_PARSE_PARAMETERS_START(1, 1)
2098+
Z_PARAM_ZVAL(a_arg)
2099+
ZEND_PARSE_PARAMETERS_END();
2100+
2101+
FETCH_GMP_ZVAL(gmpnum_a, a_arg, temp_a, 1);
2102+
RETVAL_LONG(mpz_popcount(gmpnum_a));
2103+
FREE_GMP_TEMP(temp_a);
21142104
}
21152105
/* }}} */
21162106

0 commit comments

Comments
 (0)
0