> On 05 Jan 2016, at 21:52, Andrea Faulds <a...@ajf.me> wrote:
> 
> 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.
> 
> 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’s 
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’t 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
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to