Re: Reduce execution time in loops
| From: | Andrei Zmievski | Date: | Tue, 04 Dec 2001 22:44:17 +0000 |
| Subject: | Re: Reduce execution time in loops | ||
| References: | 1 2 3 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-2131@lists.php.net to get a copy of this message | ||
On Tue, 04 Dec 2001, Victor Boivie wrote:
> $this->_sections["sl"]['properties']['rownum'] =
> $this->_sections["sl"]['properties']['iteration'];
> $this->_sections["sl"]['properties']['index_prev'] =
> $this->_sections["sl"]['properties']['index'] -
> $this->_sections["sl"]['properties']['step'];
> $this->_sections["sl"]['properties']['index_next'] =
> $this->_sections["sl"]['properties']['index'] +
> $this->_sections["sl"]['properties']['step'];
> $this->_sections["sl"]['properties']['first'] =
> ($this->_sections["sl"]['properties']['iteration'] == 1);
> $this->_sections["sl"]['properties']['last'] =
> ($this->_sections["sl"]['properties']['iteration'] ==
> $this->_sections["sl"]['properties']['total']);
I see.
> No, it's not slow. Just not as fast as it could get. (Everything can
> always be improved...)
But there is always a trade-off.
> Right now, the compiler in smarty isn't really a compiler, so it isn't
> to do speed improvements in the way "real" compilers (analyzing the
> code etc.. since smarty more or less replaces some code with other
> parts of code).. I'm well aware of that. But maybe you can add a flag
> or something?
Well, who's to say what the flag should turn off? Maybe some people have
no need for all the properties except for 'iteration'.
Making the compiler smarter (hah, a pun) would probably involve two-pass
compilation. The first pass collects all the tags and builds a list of
references. The second pass outputs the code, but it checks the
reference table and if $smarty.section.foo.iteration isn't mentioned
anywhere, then it doesn't output the code that creates that property. Of
course, this will slow down compilation and it also presents some issues
with included templates. Just an idea though, definitely not for any 1.x
release.
-Andrei
"The time from now until the completion
of the project tends to become constant." -- Douglas Hartree