Hi,

I recently profiled a symfony project (using XDebug) containing a
largish number of nested components and partials.
If I sort the profiling output by the time spent in the individual
functions, sfOutputEscaper::unescape() and html_entity_decode() are
usually among those with top ranks (specifically on position #3 and
#4, only beaten by database stuff).

Further investigation showed that this is caused by passing array
structures and objects from one component to another. The application
is configured with "escaping_strategy: on" and "escaping_method:
ESC_SPECIALCHARS", so every time data is passed from a template to a
component it gets unescaped, see PartialHelper::_call_component():

  // pass unescaped vars to the component if escaping_strategy is set
to true
  $componentInstance->getVarHolder()->add(true ===
sfConfig::get('sf_escaping_strategy') ?
sfOutputEscaper::unescape($vars) : $vars);

The next time this same data is passed to a template it gets escaped
again, only to be de-escaped later on when its used again in a
component ... Rendering the whole page invokes
sfOutputEscaper::unescape() about 20000 times!

Using nested components is a nice way to create modular pages, so
changing the basic structure seems to be no solution. So what else can
be done to optimize this situation?

I tought about using raw values in get_component(), but this is not an
option, since the decision wether unescape() (and the
html_entity_decode() function used within) is called or not is only
based on the 'sf_escaping_strategy' setting, so I would end up with
values decoded too many times.

Any suggestions for optimizing this situation?

-- 
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-us...@googlegroups.com.
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en.

Reply via email to