Skip to content

Commit 0bf11d1

Browse files
committed
Implement FAST_ZPP support for imagecolorat() and imagesetpixel()
These functions may be used in tight loops to do image manipulation in userland. Using FAST_ZPP is supposed to bring considerable performance improvements in this case; we've been able to measure up to 25%.
1 parent a565f06 commit 0bf11d1

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

ext/gd/gd.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2805,9 +2805,17 @@ PHP_FUNCTION(imagecolorat)
28052805
zend_long x, y;
28062806
gdImagePtr im;
28072807

2808+
#ifndef FAST_ZPP
28082809
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rll", &IM, &x, &y) == FAILURE) {
28092810
return;
28102811
}
2812+
#else
2813+
ZEND_PARSE_PARAMETERS_START(3, 3)
2814+
Z_PARAM_RESOURCE(IM)
2815+
Z_PARAM_LONG(x)
2816+
Z_PARAM_LONG(y)
2817+
ZEND_PARSE_PARAMETERS_END();
2818+
#endif
28112819

28122820
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
28132821
RETURN_FALSE;
@@ -3067,9 +3075,18 @@ PHP_FUNCTION(imagesetpixel)
30673075
zend_long x, y, col;
30683076
gdImagePtr im;
30693077

3078+
#ifndef FAST_ZPP
30703079
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rlll", &IM, &x, &y, &col) == FAILURE) {
30713080
return;
30723081
}
3082+
#else
3083+
ZEND_PARSE_PARAMETERS_START(4, 4)
3084+
Z_PARAM_RESOURCE(IM)
3085+
Z_PARAM_LONG(x)
3086+
Z_PARAM_LONG(y)
3087+
Z_PARAM_LONG(col)
3088+
ZEND_PARSE_PARAMETERS_END();
3089+
#endif
30733090

30743091
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
30753092
RETURN_FALSE;

0 commit comments

Comments
 (0)