You are here: Re: Why Returning References can't provide speed up? « PHP Programming Language « IT news, forums, messages
Re: Why Returning References can't provide speed up?

Posted by Rik on 02/08/07 18:43

howa <howachen@gmail.com> wrote:

> from PHP manual, it said:
>
>>> http://hk.php.net/manual/tw/language.references.return.php
>
> Do not use return-by-reference to increase performance, the engine is
> smart enough to optimize this on its own
>
> ------------------
>
> Why?

in case of

function foo(){
$bar =3D 'somestring';
return $bar;
}

The engine already knows it should be returned by reference, and does =

this. This would be plain silly:

function foo(){
$bar =3D 'somestring';
return &$bar;
}

As the engine already knows and does this.

Actually, a lot of assignments are treated as references untill you try =
to =

change one of the references, and only then is a copy made & assigned.

In other words: the engine is smarter then you think.
-- =

Rik Wasmus

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация