[wp-trac] [WordPress Trac] #10493: Allow closures as callbacks

WordPress Trac wp-trac at lists.automattic.com
Mon Sep 21 19:53:26 UTC 2009


#10493: Allow closures as callbacks
-------------------------+--------------------------------------------------
 Reporter:  scribu       |       Owner:  scribu   
     Type:  enhancement  |      Status:  new      
 Priority:  normal       |   Milestone:  2.9      
Component:  General      |     Version:  2.9      
 Severity:  normal       |    Keywords:  has-patch
-------------------------+--------------------------------------------------

Comment(by scribu):

 A performance enhancement from Nikolay was as follows:

 {{{
 if ( class_exists('Closure') ) :
   function add_filter(..) {
     // version of function that accepts closures
   }
 else :
   function add_filter(..) {
     // version of function that doesn't accept closures
   }
 }}}

 It avoids the extra if clause inside the function, when possible. The
 dissadvantage, of course, is duplicate code.

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


More information about the wp-trac mailing list