Remove unnecessary `array_shift()` usage in `get_terms()` for better performance.

props bswatson, VolodymyrC.
fixes #31182.

git-svn-id: https://develop.svn.wordpress.org/trunk@31365 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2015-02-07 19:44:13 +00:00
parent 692f79087f
commit fa1a382dff
1 changed files with 8 additions and 9 deletions

View File

@ -2013,28 +2013,27 @@ function get_terms( $taxonomies, $args = '' ) {
} }
} }
} }
reset( $terms );
$_terms = array(); $_terms = array();
if ( 'id=>parent' == $_fields ) { if ( 'id=>parent' == $_fields ) {
while ( $term = array_shift( $terms ) ) { foreach ( $terms as $term ) {
$_terms[$term->term_id] = $term->parent; $_terms[ $term->term_id ] = $term->parent;
} }
} elseif ( 'ids' == $_fields ) { } elseif ( 'ids' == $_fields ) {
while ( $term = array_shift( $terms ) ) { foreach ( $terms as $term ) {
$_terms[] = $term->term_id; $_terms[] = $term->term_id;
} }
} elseif ( 'names' == $_fields ) { } elseif ( 'names' == $_fields ) {
while ( $term = array_shift( $terms ) ) { foreach ( $terms as $term ) {
$_terms[] = $term->name; $_terms[] = $term->name;
} }
} elseif ( 'id=>name' == $_fields ) { } elseif ( 'id=>name' == $_fields ) {
while ( $term = array_shift( $terms ) ) { foreach ( $terms as $term ) {
$_terms[$term->term_id] = $term->name; $_terms[ $term->term_id ] = $term->name;
} }
} elseif ( 'id=>slug' == $_fields ) { } elseif ( 'id=>slug' == $_fields ) {
while ( $term = array_shift( $terms ) ) { foreach ( $terms as $term ) {
$_terms[$term->term_id] = $term->slug; $_terms[ $term->term_id ] = $term->slug;
} }
} }