[wp-trac] [WordPress Trac] #17201: dynamic_sidebar performance

WordPress Trac noreply at wordpress.org
Fri Aug 9 23:39:19 UTC 2013


#17201: dynamic_sidebar performance
-------------------------+------------------------------
 Reporter:  mrubiolvn    |       Owner:
     Type:  enhancement  |      Status:  reopened
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Widgets      |     Version:  3.1
 Severity:  normal       |  Resolution:
 Keywords:  close        |
-------------------------+------------------------------

Comment (by brianvan):

 Not sure if it's relevant but ticket #5326 addressed sanitize_title() on
 widget IDs and recommended purging use of the function from newer API
 constructs because of its poor performance
 http://core.trac.wordpress.org/ticket/5326

 A quick look at sanitize_title() shows that it's a small function that
 includes an apply_filters() call that we may want to unwind to see how
 many expensive functions are being called for it. It also calls
 remove_accents(), and that function includes almost 800 calls to chr()
 plus a few calls to strtr() that may or may not be performance
 bottlenecks. Some sites say strtr() is performant, but then there's this:
 http://www.simplemachines.org/community/index.php?topic=175031.0

 Another performance observation: dynamic_sidebar() calls the very
 expensive sanitize_title() function simply to compare two previously-
 unsanitized titles for a match. For this purpose, is the sanitization
 needed during iteration, or should it just be done right after foreach()?
 That would save a majority of the calls to sanitize_title().

 Or if that's not acceptable, I wonder if any part of register_sidebar()
 (including actions attached within) are already calling sanitize_title()
 on widget titles. Maybe that data can be persisted in the widget
 object/array to avoid repeat sanitization calls later? Even just inserting
 a new sanitize_title() call once for every sidebar during registration is
 almost always more efficient than calling it on an average of half the
 array for every display_sidebar() call, with few exceptions.

--
Ticket URL: <http://core.trac.wordpress.org/ticket/17201#comment:8>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list