[development] passing data is free
Karoly Negyesi
karoly at negyesi.net
Mon Oct 8 22:06:44 UTC 2007
To quote one of the most experienced Drupal developer:
"The menu item array includes a copy of the whole node for example on
node pages. Well, obviously that might be useful for some help stuff,
but most of the time it is not required, so why pass on this data in
all cases?"
Why not? Passing data around is basically free. You are not copying
the data, you are creating a reference, deep copy only happens if you
modify the passed in argument (PHP5 only deep copies an object if you
instruct it with clone()). So do not hesitate to pass around as many
data as you want.
Not for the first time I urge fellow developers to read
http://web.archive.org/web/20061205052540rn_1/www.zend.com/zend/art/ref-count.php
this excellent article which is so old that you need archive.org to
read it but is still valid.
For deeper understanding read
http://book.chinaunix.net/special/ebook/php/Programming.PHP_2/0596006810/progphp2-CHP-14.html
More information about the development
mailing list