[wp-trac] [WordPress Trac] #14429: Faster is_serialized

WordPress Trac wp-trac at lists.automattic.com
Tue Sep 7 18:25:53 UTC 2010

#14429: Faster is_serialized
 Reporter:  sambauers     |       Owner:           
     Type:  enhancement   |      Status:  new      
 Priority:  normal        |   Milestone:  3.1      
Component:  Optimization  |     Version:  3.0      
 Severity:  minor         |    Keywords:  has-patch

Comment(by ryan):

 With a default scratch install with the Links widget added, this reduces
 the number of calls to preg_match from 233 to 45.  strpbrk is called 164
 times and function_exists is called 188 times.  is_serialized went from
 spending 6-10% of its time running preg_match to 2% of its time running
 preg_match and a fraction of a percent running strpbrk and
 function_exists. strlen() > 1 eliminated 24 strings from further
 processing (probably 0|1|Y|N flags).  An empty() check didn't eliminate
 any further strings, so I left it out.

 This could be further optimized by moving the strlen check up and caching
 the function_exists results. The function_exists check will disappear in
 3.2, however, so worrying too much about it now is probably not

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

More information about the wp-trac mailing list