[wp-trac] Re: [WordPress Trac] #6464: convert_smilies is very slow

WordPress Trac wp-trac at lists.automattic.com
Mon Jan 5 21:35:14 GMT 2009


#6464: convert_smilies is very slow
--------------------------+-------------------------------------------------
 Reporter:  Acci          |        Owner:  anonymous
     Type:  defect (bug)  |       Status:  new      
 Priority:  normal        |    Milestone:  2.8      
Component:  Optimization  |      Version:           
 Severity:  normal        |   Resolution:           
 Keywords:                |  
--------------------------+-------------------------------------------------
Changes (by johanee):

  * milestone:  2.9 => 2.8

Comment:

 Patch added for this. Also, I think it should go in before 2.9.

 This patch changes smilies_init and convert_smilies to make a more
 efficient regular expression resulting in a ~10times speedup.

 This is done by:
 o the search expression is built up as sub-expressions for smiley first
 letter (example of partial result: "8(\)|-\)|-O|O)").
 o to handle the replacement preg_replace_callback() in convert_smilies.

 Resulting generated search regular expression for default smilies:
 "/(\s|^)8(\)|-\)|-O|O)|\:(\!\:|\(|\)|-\(|-\)|-\?|-D|-P|-o|-x|-\||\?|\?\:|\?\?\?\:|D|P|arrow\:|cool\:|cry\:|eek\:|evil\:|grin\:|idea\:|lol\:|mad\:|mrgreen\:|neutral\:|o|oops\:|razz\:|roll\:|sad\:|shock\:|smile\:|twisted\:|wink\:|x|\|)|;(\)|-\))(\s|$)/e"

 Load time on the site for a post with 403 comments:
 Original: 4.3s
 Modified: 2.6s

-- 
Ticket URL: <http://trac.wordpress.org/ticket/6464#comment:3>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list