[htmltmpl] Re: Patches for HTML-Template-2.5.tar.gz
Brought to you by:
samtregar
From: Sam T. <sa...@tr...> - 2002-07-25 16:30:46
|
On Thu, 25 Jul 2002, Yunliang Yu wrote: > Process with standard HTML::Template 1.52s > Process with my patched version 1.56s > Process with HTML::Template::Expr 2.39s > > => patched version has 2.4% overhead, ::Expr 57% overhead Did you enable any caching? I would expect HTML::Template::Expr to lose with caching off since it has to run a rather expensive parse on every call. > I didn't test memory usages, but changing "$value" to "->{value}=$value" > adds a hash with only one element and shouldn't have too much impact. Hashes automatically make room for multiple elements on the assumption that they won't be used to store just one. I think you'll be surprised how much bigger a one-element hash is! I think a better implementation of defaulting would put the default onto the stack ahead of the variable. Then output can just look ahead and see if the variable is defined to decide whether to output the value. > > Why did you force global_vars on for associate? What does > > explicit_global_vars do exactly? It's not documented. > > $global_vars and $options->{global_vars} are totally different. Turning on > $global_vars doesn't turn global_vars on. The main reason that I made the > changes is to avoid global_vars and have expr support. I still don't understand. > 'VALUE=' was chosen so it looks similar to: > <INPUT TEXT NAME="Name" VALUE="Department of Mathematics"> Well, sure, but it doesn't do the same thing! To me <tmpl_var name=foo value=bar> looks like the variable foo is being assigned a value of "bar". Assuming that I would be very surprised to find the tag outputting "baz" because there's a $template->param(foo => 'baz') in a Perl file somewhere! To me, DEFAULT gets the provisional nature of the assignment across better. > In one project, every page is designed by users, the programmer can't tell > what data the page wants just by looking at the url. TMPL_DEF is the way > the user passes requests back to the programmer. This way the user can > create any url with any data, and the programmer only computes what's > needed from the backend database. TMPL_DEF was introduced since it has > not output. $template->query() can be used for this purpose instead. Just look at the TMPL_VARs and TMPL_LOOPs that the user is requesting and you'll know what to provide. -sam |