Posted by Toby A Inkster on 05/14/07 21:36
NoWhereMan wrote:
> well IIRC I read something about using .join() instead of += in a guide
> about optimizing JavaScript (this applies to Java as well, though); I
> thought it could be applied to PHP too.
The way Javascript deals with strings is entirely different to the way PHP
does. In Javascript, strings are an immutable object, so the += operator
doesn't just concatenate one new string onto an existing string object --
it creates a brand new string object then reassigns the old string object
variable to point to the new object, marking the old object for garbage
collection.
--
Toby A Inkster BSc (Hons) ARCS
http://tobyinkster.co.uk/
Geek of ~ HTML/SQL/Perl/PHP/Python/Apache/Linux
[Back to original message]
|