Ok, it’s time to diss some people. Let’s take a look at Pimcore’s “autoload-classmap.php“. You’ll find this file over at Github.
The file, as the name suggests, contains the classmap definition for the whole Pimcore universe. This file contains 20493 occurrences of $dsp, where $dsp is a variable, which gets the DIRECTORY_SEPARATOR assigned to, on line 3. Now 20492 occurrences are left. Each variable evaluation is followed by two concatenation operations. The dot is the concatenation operator in PHP, for putting two strings together. The two concats are used for gluing the folder names together, to finally build up the full qualified path to the class, which is needed for the inclusion of the file, by looking up its classname in the array.
Even if this classmap is placed in memory after the first inclusion, it’s a lot of overhead. A lot! 20492 var evals + 40984 concat operations = 61476 unnecessary operations.
Should we take a look at the PHP opcodes? Better not..
How to avoid this? It’s simple. Replace “‘ . $dsp . ‘” by “/”.
Both, Windows and Linux support “/” – so what is the problem in using it?
Now, let’s take a look at the variable $pdr. It gets PIMCORE_DOCUMENT_ROOT assigned on line 2.
Let’s replace your funny ” . $pdr . ” . $dsp . ‘pimcore’ with $pdr . ‘/pimcore/more/folders’.
Update 09.04.2013:
Finally, someone decided to accept the solution proposed here and updated the file accordingly.
The new mechanism looks like this: https://github.com/pimcore/pimcore/commit/3cec4543dbc658c8b59ab23daf2d84ab26b11ca2
Congratulations. https://github.com/pimcore/pimcore/blob/master/pimcore/config/autoload-classmap.php