[wp-trac] [WordPress Trac] #20126: get_file_data() is obtuse
WordPress Trac
wp-trac at lists.automattic.com
Sun Feb 26 22:19:11 UTC 2012
#20126: get_file_data() is obtuse
--------------------------+-----------------
Reporter: nacin | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 3.4
Component: Performance | Version:
Severity: normal | Keywords:
--------------------------+-----------------
get_file_data() employs two odd-looking constructs. This is to make keys
equal the values:
{{{
$extra_headers = array_flip( $extra_headers );
foreach( $extra_headers as $key=>$value ) {
$extra_headers[$key] = $key;
}
}}}
A single array_combine() will clean this up.
Later, it uses ${$field}, followed by a `return compact( array_keys( ) )`,
rather than simply building the output array in the format for which it is
returned.
Attached is a simple patch that shortens the function while making it
easier to understand, and introduces some small performance gains.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/20126>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list