Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81757 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10533 invoked from network); 4 Feb 2015 04:02:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Feb 2015 04:02:25 -0000 Authentication-Results: pb1.pair.com smtp.mail=xinchen.h@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=laruence@php.net; sender-id=unknown Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.215.53 as permitted sender) X-PHP-List-Original-Sender: xinchen.h@zend.com X-Host-Fingerprint: 209.85.215.53 mail-la0-f53.google.com Received: from [209.85.215.53] ([209.85.215.53:60654] helo=mail-la0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C1/01-20608-DC991D45 for ; Tue, 03 Feb 2015 23:02:22 -0500 Received: by mail-la0-f53.google.com with SMTP id gq15so55979340lab.12 for ; Tue, 03 Feb 2015 20:02:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=PQS/xfH2gtk41Rbq5rjYfCIR7gUqoI0noeX19GRk0F4=; b=K7AqTaM40QU6vLnPqt30lFNuXHRi56c/pHhjMz8DY3taCb2ZqjDKyrnHKZ8F/h6GBI wC3vNPiGn3jhMz1aWg2z6CRNYPM5Kkj2TI2qAwKEZjiRstXRzI4it/6E9hfRsjU8rYd5 DCfy8WwHy6ZY3brt51FAiMjD/83VyviF9YNtEZZYNjYl4sdvI5YKSMYi2C6d3QJzP/7F Iw+QV6/zoGd5IUlGi3cSL/ApaZPmIbnt59ZttBqs3RCRZvAb4pF6I7h8BC8pmJR9iqwI TNOxLpyjZ/pZl13Z2atxxTV4xmLFN5qJXSEgqHzzODCZzgcgw5/Xp4oK7t1UJxFj8Pta is1A== X-Gm-Message-State: ALoCoQmX9lhsLXiHxTURNmKtj2IpLCV497L1Oycu3DaTRqSTwrPC2u4//+15bIWBiZFPTdt/97061fBj2uoPSr7734N+bhMy6AnwXdzBMUxVSfI7Ssumxo4YBu6bYoTRzLsxR4m5kPYioiXc+SggQI/l52sXMukS8g== X-Received: by 10.152.242.132 with SMTP id wq4mr8024221lac.79.1423022538510; Tue, 03 Feb 2015 20:02:18 -0800 (PST) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPSA id ay2sm90677lab.37.2015.02.03.20.02.17 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 03 Feb 2015 20:02:17 -0800 (PST) Received: by mail-lb0-f171.google.com with SMTP id u14so42100791lbd.2 for ; Tue, 03 Feb 2015 20:02:16 -0800 (PST) X-Received: by 10.112.198.1 with SMTP id iy1mr27948920lbc.13.1423022536506; Tue, 03 Feb 2015 20:02:16 -0800 (PST) MIME-Version: 1.0 Received: by 10.114.28.193 with HTTP; Tue, 3 Feb 2015 20:01:56 -0800 (PST) In-Reply-To: References: Date: Wed, 4 Feb 2015 12:01:56 +0800 Message-ID: To: PHP Internals , Dmitry Stogov Content-Type: text/plain; charset=UTF-8 Subject: Re: [DICUSS]Cleanup resource handling APIs From: laruence@php.net (Xinchen Hui) Hey: On Mon, Feb 2, 2015 at 1:34 PM, Xinchen Hui 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 merged, all tests passes. thanks > > -- > Xinchen Hui > @Laruence > http://www.laruence.com/ -- Xinchen Hui @Laruence http://www.laruence.com/