Re: [SMARTY] Smarty 2.6.0 RC1 - Change in path handling
| From: | Mark Rogers | Date: | Wed, 13 Aug 2003 14:50:53 +0000 |
| Subject: | Re: [SMARTY] Smarty 2.6.0 RC1 - Change in path handling | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-10061@lists.php.net to get a copy of this message | ||
David wrote:
> yeah, that's what I thought about, too... multiple
> template directories will result in a noticeable
> performance impact... ;/
Well it was there already, and is also there in 2.6 (it's just that the way
that the array of template directories is created prior to looping breaks if
the existing template_dir is an array).
I haven't done any benchmarks, but I doubt that the overhead of the foreach
loop has any impact IF the array being looped through has only one value in
it. Ie:
$path = '/some/path/';
if (file_exists($path.'somefile.tpl')) {
// Do something
}
.. is unlikely to be any slower (in real terms) than:
$paths = array('/some/path/');
foreach ($paths as $path) {
if (file_exists($path.'somefile.tpl')) {
// Do something
}
}
Of-course if $paths has more than one entry then there will be an overhead
(in other words it only has an impact if you use it). Even then there is
only an impact if the template is not in the main path and it has to go
further looking for it, which for most sites would not be the normal case.
It is important to understand that the current code (ie 2.6.0 RC1) takes
your path, converts it to an array (by inserting into an empty array),
appends the current directory ('.') to the array, then loops through that
array - so in practise the (negligible) overhead is already there. The only
change I'm asking for is that this still works if the path is an array to
begin with.
The old code (2.5 and earlier) takes your path, converts it to an array (via
a typecast), and loops through it - the only functional difference being
that it doesn't append '.' to the array. A side effect of the different way
it does this compared with 2.6 is that if the path is already an array it
survives this conversion (in 2.6 it doesn't - you end up with an array
inside an array).
Apologies to all for confusing the issue and saying this was a bug to start
with; I'd have explained it better from the outset had I been more careful
in checking what the documented behaviour is. It is the fact that the old
code typecasts to an array then loops through it (without appending anything
to it) which lead me to believe that arrays were supported at this stage (I
could see no other reason for this typecast).
Mark Rogers,
More Solutions Ltd