[Typo3-dev] makeInstance and references

Martin Kutschker Martin.T.Kutschker at blackbox.net
Mon Sep 8 13:36:48 CEST 2003


Hi!

As far as I have understood the docs on php.net, a reference is a kind of an alias for an object. Which means making a reference creates a new entry in a symbol table. If you copy the object the former is done for the object and ALL its properties. I should think that using references s) increases speed and b) decreases memory usage.

I'd go for it!

For makeInstance this can be achieved by changing the declaration from
function &makeInstance($className) 
to
function &makeInstance($className) 

But you have to change ALL calls to it to use =& instead of =.

You can do this with find and perl in the src directory:

find -name "*.php" -exec perl -npi -e "s/=( )*t3lib_div::makeInstance\(/=&\1t3lib_div::makeInstance(/g" \{} \;

Note: there is one space in =( )*. Just in case it gets wrapped.

I don't expect any troubles by this straightforward change. I'll use this setting for our development servers.

Masi 





More information about the TYPO3-dev mailing list