Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79335 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 540 invoked from network); 1 Dec 2014 11:08:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Dec 2014 11:08:17 -0000 Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.220.169 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.220.169 mail-vc0-f169.google.com Received: from [209.85.220.169] ([209.85.220.169:44008] helo=mail-vc0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AC/80-29154-E1C4C745 for ; Mon, 01 Dec 2014 06:08:16 -0500 Received: by mail-vc0-f169.google.com with SMTP id hy10so4609011vcb.0 for ; Mon, 01 Dec 2014 03:08:12 -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:date :message-id:subject:from:to:cc:content-type; bh=af/hmvx+Nr3JTDLKDBTUOCNNHkddAeT2cdpn1LURFRc=; b=hATs8EgmdwlaKa6vmg2AeiL6Qc4qAgNERje/I38r0dOQvPZEBS6MeIJ27q6wuLLCX3 vNwAhZVg8luJTtgLnIg5LXZUR/QoyEzDk4KevJIvYr/BTmRKf/89Zy4o+lGQOyR69+xu ng6huwK+eQHa7FWMJWUAG/8QwFpe4QPINqCoNCVJMrJkhGEqBtYcqzvBLLNROLeFQg1m vOreFpB+4fED0PY/mHvqCWb6GLaDs2EREgyKcTxPv4CN+oaFwbkmmHlY+l9tJfyEdmvu D1wncuNqGVI4397f/40uWaSHpd2wZYD4UuBXLYXZAkG9fhA5oBEghTpBM87vaTt6ugU2 yGTg== X-Gm-Message-State: ALoCoQntBvlV4aHXfAnak7NXaljwOJc8a6zpq8dUP05jAfjIxyI3cqHTe/rjI0m1wgAb2+Cvb5Xw7TfhOh4VKz3bgwR4sAIAysDs+s4R16fh9PcIOZnJstXiI73L5cCbICMBIfhr4Q0s0/syQC110BPVnOZDDKH4qA== MIME-Version: 1.0 X-Received: by 10.220.74.197 with SMTP id v5mr2845478vcj.27.1417432092100; Mon, 01 Dec 2014 03:08:12 -0800 (PST) Received: by 10.52.176.231 with HTTP; Mon, 1 Dec 2014 03:08:11 -0800 (PST) In-Reply-To: References: Date: Mon, 1 Dec 2014 15:08:11 +0400 Message-ID: To: Levi Morrison Cc: Nikita Popov , Xinchen Hui , Stanislav Malyshev , Anatol Belski , PHP Internals Content-Type: multipart/alternative; boundary=089e0160b76e57e1db050925a064 Subject: Re: [PHP-DEV] Use zend_string* for op_array->arg_info[].name and class_name From: dmitry@zend.com (Dmitry Stogov) --089e0160b76e57e1db050925a064 Content-Type: text/plain; charset=UTF-8 See the updated patch: https://gist.github.com/dstogov/08b545de6bf113113f58 it can be safely applied again and simplifies inheritance code (thanks to Levi). The patch saves 60K (0.5%) of code segment, and make very slight speed improvement (visible with callgrind) All tests are passed. I think now the inheritance code is clear enough. Thanks. Dmitry. On Mon, Dec 1, 2014 at 11:02 AM, Dmitry Stogov wrote: > Hi Levi, > > I understood, that you don't see a big problems with the patch. :) > > According to your suggestions, It's possible to do it in this way, but > it's going to be slower, because it would require additional memory > allocation, but I agree that duplicating logic in the code isn't good. > It must be better to write something like the following (I didn't test it, > but it'll work): > > I'll update the patch. > > Thanks. Dmitry. > > char *class_name; > size_t class_name_len; > > if (fe->type == ZEND_INTERNAL_FUNCTION) { > class_name = ((zend_internal_arg_info*)fe_ > arg_info)->class_name; > class_name_len = strlen(class_name); > } else { > class_name = fe_arg_info->class_name->val; > class_name_len = fe_arg_info-> > class_name->len; > } > > if (class_name_len == sizeof("parent")-1 && > !zend_binary_strcasecmp(class_name, "parent", sizeof("parent")-1, > sizeof("parent")-1) && > proto->common.scope) { > fe_class_name = zend_string_copy(proto->common.scope->name); > } else if (class_name_len == sizeof("self")-1 && > !zend_binary_strcasecmp(class_name, "self", sizeof("self")-1, > sizeof("self")-1) && > fe->common.scope) { > fe_class_name = zend_string_copy(fe->common.scope->name); > } else { > fe_class_name = class_name; > } > > > On Fri, Nov 28, 2014 at 11:19 PM, Levi Morrison wrote: > >> > Please review the patch >> https://gist.github.com/dstogov/47a39aff37f0a6441ea0 >> >> Instead of duplicating logic in two places I'd rather grab the >> relevant data first, then do the logic once: >> >> zend_string *class_name; >> if (fe->type == ZEND_INTERNAL_FUNCTION) { >> class_name = zend_string_init( >> ((zend_internal_arg_info*)fe_arg_info)->class_name, >> strlen(((zend_internal_arg_info*)fe_arg_info)->class_name), 0 >> ); >> } else { >> class_name = zend_string_dup(fe_arg_info->class_name); >> } >> >> if (!zend_string_equals_literal_ci(class_name, "parent") && >> proto->common.scope) { >> fe_class_name = zend_string_copy(proto->common.scope->name); >> } else if (!zend_string_equals_literal_ci(class_name, "self") && >> fe->common.scope) { >> fe_class_name = zend_string_copy(fe->common.scope->name); >> } else { >> fe_class_name = class_name; >> } >> zend_string_release(class_name); >> > > --089e0160b76e57e1db050925a064--