Hey:

     we used to use lval of zval as a handle to access resource type..

     but now, we introduced a new type IS_RESOURCE, which make the
handle(id) sort of redundant .

     further more, the common usage when handling resource is like:

      if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &result,
&offset) == FAILURE) {
        return;
    }
    ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL
result", le_result);

    as you can see, we use "r" to receive a IS_RESOURCE type, that
means, check the type in ZEND_FETCH_RESOURCE is overhead..

   and:

   ZEND_API void *zend_fetch_resource(zval *passed_id, int default_id,
const char *resource_type_name, int *found_resource_type, int
num_resource_types, ...)

   we use va_args to passing resource type, that means, the rescue
type arguments can not be passed by register but by stack.. which is a
little low effiicient .

   so, I'd like propose a zend_resource handling API cleanup..

   1.  DROP ZEND_REGISTER_RESOURCE/FETCH_RESOURCE.

   2.  add :

       ZEND_API void *zend_fetch_resource(zend_resource *res, const
char *resource_type_name, int resource_type);
ZEND_API void *zend_fetch_resource2(zend_resource *res, const char
*resource_type_name, int *found_type, int resource_type, int
resource_type2);
ZEND_API void *zend_fetch_resource_ex(zval *res, const char
*resource_type_name, int resource_type);
ZEND_API void *zend_fetch_resource2_ex(zval *res, const char
*resource_type_name, int *found_type, int resource_type, int
resource_type2);

   a underworking patch could be found at:
https://github.com/php/php-src/pull/1042

   any ideas & objections?

thanks

-- 
Xinchen Hui
@Laruence
http://www.laruence.com/

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to