[wp-trac] [WordPress Trac] #18230: Optimize wp_list_pluck

WordPress Trac wp-trac at lists.automattic.com
Sun Jul 24 08:56:54 UTC 2011


#18230: Optimize wp_list_pluck
-------------------------+------------------
 Reporter:  Otto42       |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  3.3
Component:  Performance  |     Version:
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |
-------------------------+------------------

Comment (by xknown):

 Using isset instead of is_object is a little bit faster apparently.
 {{{
 function new_wp_list_pluck( $list, $field ) {
         foreach ( $list as $key => $value ) {
                 if ( isset( $value->$field ) ) $list[$key] =
 $value->$field;
                 else $list[$key] = $value[ $field ];
         }

         return $list;
 }
 }}}

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


More information about the wp-trac mailing list