Re: [DICUSS]Cleanup resource handling APIs
| From: | Xinchen Hui | Date: | Mon, 02 Feb 2015 10:48:31 +0000 |
| Subject: | Re: [DICUSS]Cleanup resource handling APIs | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-81579@lists.php.net to get a copy of this message | ||
Hey:
if no objections, I will commit it.. (no bc breaks, no handle
removing , only APIs change)
dmitry suggest we change zend_fetch_resource to
zend_verify_resource, I think it make sense.. will do it.
thanks
On Mon, Feb 2, 2015 at 1:34 PM, Xinchen Hui <laruence@php.net> wrote:
> 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/
--
Xinchen Hui
@Laruence
http://www.laruence.com/