Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98612 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 51230 invoked from network); 23 Mar 2017 22:25:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Mar 2017 22:25:55 -0000 X-Host-Fingerprint: 78.45.157.16 ip-78-45-157-16.net.upcbroadband.cz Received: from [78.45.157.16] ([78.45.157.16:23140] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 44/41-40046-07B44D85 for ; Thu, 23 Mar 2017 17:25:54 -0500 To: internals@lists.php.net Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes References: Date: Thu, 23 Mar 2017 23:25:44 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: Quoted-Printable Message-ID: User-Agent: Opera Mail/1.0 (Win32) X-Posted-By: 78.45.157.16 Subject: Re: TOKEN_AS_OBJECT for token_get_all() From: j.tvr@centrum.cz (=?utf-8?Q?Jan_Tvrd=C3=ADk?=) On Thu, 23 Mar 2017 18:16:31 +0100, Nikita Popov = = wrote: > Hi internals, > > I'd like to add a new TOKEN_AS_OBJECT flag to token_get_all(), which > returns an array of PhpToken objects, rather than the mix of plain = > strings > and arrays we currently have. The PhpToken class is defined as: > > class PhpToken { > public $type; > public $text; > public $line; > } > > This has been previously suggested and implemented by Rouven We=C3=9Fl= ing [1], > I've just ported this feature to master and optimized the implementati= on > [2]. > > Apart from being a nicer interface than the current format, an additio= nal > advantage is that the TOKEN_AS_OBJECT mode uses about 1.8x less memor= y = > and > is 1.4x times faster. > > Are there any objections to this change? > > Regards, > Nikita > > [1]: https://github.com/php/php-src/pull/1727 > [2]: https://github.com/php/php-src/pull/2430 Regarding memory - would it be possible to return iterator instead of = array? Regards, Jan Tvrdik