Re: Return Values Copied? Copied if By Reference?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2006-07-27 at 01:35, Larry Garfield wrote:
> On Wednesday 26 July 2006 21:41, Robert Cummings wrote:
> 
> > > I'm working on some code that would be called to generate a cell in a
> > > possibly large table and therefore a small difference in performance
> > > may have a significant impact.
> >
> > PHP uses copy-on-write and so copies are essentially shared until such
> > time as you modify one of them. If you don't need references then copies
> > are faster than references.
> 
> By the same token, then, if I have a function that generates a large string 
> and returns it, is there any benefit to return-by-reference?

Nope. You should only use references if you really need them. Attempting
to improve efficiency by using references instead of copies when you
aren't actually in need of a reference will result in less efficiency
since the engine spends more time creating the reference than the copy.

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux