Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:90570 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 17519 invoked from network); 12 Jan 2016 17:07:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Jan 2016 17:07:24 -0000 Authentication-Results: pb1.pair.com header.from=me@rouvenwessling.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=me@rouvenwessling.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain rouvenwessling.de from 80.241.60.215 cause and error) X-PHP-List-Original-Sender: me@rouvenwessling.de X-Host-Fingerprint: 80.241.60.215 mx2.mailbox.org Received: from [80.241.60.215] ([80.241.60.215:38572] helo=mx2.mailbox.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7B/D4-27877-9C235965 for ; Tue, 12 Jan 2016 12:07:22 -0500 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id E912B4212B; Tue, 12 Jan 2016 18:07:18 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by gerste.heinlein-support.de (gerste.heinlein-support.de [91.198.250.173]) (amavisd-new, port 10030) with ESMTP id 6P1m0zobFqIv; Tue, 12 Jan 2016 18:07:17 +0100 (CET) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 9.1 \(3096.5\)) In-Reply-To: <77.F6.12097.81D2C865@pb1.pair.com> Date: Tue, 12 Jan 2016 18:07:16 +0100 Cc: internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: References: <77.F6.12097.81D2C865@pb1.pair.com> To: Andrea Faulds X-Mailer: Apple Mail (2.3096.5) Subject: Re: [PHP-DEV] Re: [RFC] Normalize token_get_all() output (with flag) From: me@rouvenwessling.de (=?utf-8?Q?Rouven_We=C3=9Fling?=) > On 05 Jan 2016, at 21:52, Andrea Faulds wrote: >=20 > This is more of a side-note, but maybe it's worth bringing up. Since = token_get_all gives an array with subarrays of a regular structure, = might it be worthwhile returning an array of objects instead? It would = probably reduce memory usage (assuming they're objects of a Token class = or something, not StdClass), but I don't know if it's that useful. >=20 > Thoughts? I liked the idea so I went ahead and tested it. Code is here: = https://github.com/php/php-src/pull/1727 Doing some incredibly simplistic testing using a modified version of = Nikita=E2=80=99s PHP-Parser. It saved ~10% in memory (just parsing the = parser itself and immediately discarding the result) and speed up within = the margin of error. The proposal from Sara would probably take slightly = more memory than the current code since there would be more arrays = allocated. In terms of performance that doesn=E2=80=99t seem like a big win. But = objects are niece for another reason: IDEs (and potentially other tools) = know about them and will warn you about typos in properties. Best regards Rouven=