[wp-trac] [WordPress Trac] #13662: Admin Menu Generation - Speedup, Cleanup

WordPress Trac wp-trac at lists.automattic.com
Mon May 31 19:18:20 UTC 2010


#13662: Admin Menu Generation - Speedup, Cleanup
--------------------------+-------------------------------------------------
 Reporter:  dragoonis     |       Owner:                              
     Type:  enhancement   |      Status:  new                         
 Priority:  normal        |   Milestone:  Unassigned                  
Component:  Optimization  |     Version:  3.0                         
 Severity:  normal        |    Keywords:  admin menu, speedup, cleanup
--------------------------+-------------------------------------------------
 '''Speed improvements to _wp_menu_output()'''
 [[BR]][[BR]]

 '''Speedup'''
 [[BR]][[BR]]
 More ternaries vs basic if/else statements.[[BR]][[BR]]
 Assignment to reduce multi dimension references:
 {{{
 $submenu_items = $submenu[$item[2]];
 }}}
 So we don't have to do index lookups like
 {{{
 $submenu[$item[2]][0][2]
 }}}

 Speedup such as:[[BR]]
 {{{
 if(file_exists() || empty())
 }}}
 to:
 {{{
 if(empty() || file_exists())
 }}}
 [[BR]]
 '''Readability'''
 {{{
 if ( false !== $pos = strpos($menu_file, '?') )
 }}}
 to:
 {{{
 if ( false !== ($pos = strpos($menu_file, '?')) )
 }}}
 [[BR]]
 '''Speedup, Readability and Maintainability'''
 [[BR]]
 from: One big 1-liner if statement[[BR]]
 to:[[BR]]
 (I have moved the main '''OR''' branch to now have the small condition
 first, whereas it was last before.)[[BR]]
 (I have restructured the IF to become readable and some usage of
 '''===''')
 {{{
 } else if (
     (!isset($plugin_page) && $self == $sub_item[2]) ||
     (isset($plugin_page)
         && $plugin_page == $sub_item[2]
         && (($item[2] == $self_type) || ($item[2] == $self) ||
 file_exists($menu_file) === false)
 )) {
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/13662>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list