]> granicus.if.org Git - php/commitdiff
Implement FAST_ZPP support for imagecolorat() and imagesetpixel()
authorChristoph M. Becker <cmbecker69@gmx.de>
Fri, 2 Sep 2016 17:06:26 +0000 (19:06 +0200)
committerChristoph M. Becker <cmbecker69@gmx.de>
Fri, 2 Sep 2016 17:06:26 +0000 (19:06 +0200)
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%.

ext/gd/gd.c

index 332bd5a408dbcb320334aba2d0a6b16df54089dc..5149db48bbf76bb15289b50e6569325a6a888157 100644 (file)
@@ -2805,9 +2805,17 @@ PHP_FUNCTION(imagecolorat)
        zend_long x, y;
        gdImagePtr im;
 
+#ifndef FAST_ZPP
        if (zend_parse_parameters(ZEND_NUM_ARGS(), "rll", &IM, &x, &y) == FAILURE) {
                return;
        }
+#else
+       ZEND_PARSE_PARAMETERS_START(3, 3)
+               Z_PARAM_RESOURCE(IM)
+               Z_PARAM_LONG(x)
+               Z_PARAM_LONG(y)
+       ZEND_PARSE_PARAMETERS_END();
+#endif
 
        if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
                RETURN_FALSE;
@@ -3067,9 +3075,18 @@ PHP_FUNCTION(imagesetpixel)
        zend_long x, y, col;
        gdImagePtr im;
 
+#ifndef FAST_ZPP
        if (zend_parse_parameters(ZEND_NUM_ARGS(), "rlll", &IM, &x, &y, &col) == FAILURE) {
                return;
        }
+#else
+       ZEND_PARSE_PARAMETERS_START(4, 4)
+               Z_PARAM_RESOURCE(IM)
+               Z_PARAM_LONG(x)
+               Z_PARAM_LONG(y)
+               Z_PARAM_LONG(col)
+       ZEND_PARSE_PARAMETERS_END();
+#endif
 
        if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
                RETURN_FALSE;