Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81546 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 53271 invoked from network); 2 Feb 2015 05:35:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Feb 2015 05:35:20 -0000 Authentication-Results: pb1.pair.com header.from=laruence@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=xinchen.h@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.215.44 as permitted sender) X-PHP-List-Original-Sender: xinchen.h@zend.com X-Host-Fingerprint: 209.85.215.44 mail-la0-f44.google.com Received: from [209.85.215.44] ([209.85.215.44:47015] helo=mail-la0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id ED/30-47540-59C0FC45 for ; Mon, 02 Feb 2015 00:35:18 -0500 Received: by mail-la0-f44.google.com with SMTP id s18so37344309lam.3 for ; Sun, 01 Feb 2015 21:35:14 -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:from:date:message-id:subject:to :content-type; bh=mzmEWC6FTyvGaXnlC27iDiWM4TCUjnx18kHFwkKU/AM=; b=O+QkbUKtQuLwvz+kO6vqPK5QecoIOuK77ysyJ86dNhwsAgtbxaMNhVqg/VoI+RRxfl ozeg1lyBa/DHmHXnPqbE7MKPctsnzSudYJbogX2iDSjJ04ogzvsQQNinBRpHr227aHyY 1pQL0eHVvQ8R7M9GHPtaWaEtCAFmmEqvRLt+MpOKlUG/ei8D6v5E8qCMW71rQw/mZKjp PzRaBr0Yqpd7Tdby3jZvu+Cdcx+EEXJpDts6qW9zrRJ+DxNfe02I7idWcG/AWj9FCdkV PJkXc9BSsUw/RD27YUUpUzWe6G4zxwr4SPyn3Rbwm8eSkSqPjFjZ+RQ2kuV1g/+3Dei5 nVtw== X-Gm-Message-State: ALoCoQn4+TsMiz0AqUkG4eH6oXTtRGLSJKLoR8XKoSh/Kclx4x3deTmsl9OshaWf1UhnaKrZH5WKPsyII4y9NxAqc55cG7QVn8GA4Is4GKtS2raXnT2HxQMrh18CE7mmx6IYK5shKnZ4bGymDOLVZTUUHrElyKXOYA== X-Received: by 10.112.132.2 with SMTP id oq2mr17759714lbb.11.1422855314356; Sun, 01 Feb 2015 21:35:14 -0800 (PST) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPSA id rn9sm1371923lbb.23.2015.02.01.21.35.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 01 Feb 2015 21:35:13 -0800 (PST) Received: by mail-la0-f44.google.com with SMTP id s18so37344082lam.3 for ; Sun, 01 Feb 2015 21:35:12 -0800 (PST) X-Received: by 10.112.140.196 with SMTP id ri4mr17600393lbb.55.1422855312127; Sun, 01 Feb 2015 21:35:12 -0800 (PST) MIME-Version: 1.0 Received: by 10.114.28.193 with HTTP; Sun, 1 Feb 2015 21:34:51 -0800 (PST) Date: Mon, 2 Feb 2015 13:34:51 +0800 Message-ID: To: PHP Internals , Dmitry Stogov Content-Type: text/plain; charset=UTF-8 Subject: [DICUSS]Cleanup resource handling APIs From: laruence@php.net (Xinchen Hui) 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/