From 09c1d34b96013271345ee21cd146ef669bbb1776 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 7 Feb 2015 19:45:25 +0000 Subject: [PATCH] Remove unnecessary `array_shift()` usage in `get_terms()` for better performance. props bswatson, VolodymyrC. fixes #31182. Built from https://develop.svn.wordpress.org/trunk@31365 git-svn-id: http://core.svn.wordpress.org/trunk@31346 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/taxonomy.php | 17 ++++++++--------- wp-includes/version.php | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 6deb0030d4..142ef28c64 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -2013,28 +2013,27 @@ function get_terms( $taxonomies, $args = '' ) { } } } - reset( $terms ); $_terms = array(); if ( 'id=>parent' == $_fields ) { - while ( $term = array_shift( $terms ) ) { - $_terms[$term->term_id] = $term->parent; + foreach ( $terms as $term ) { + $_terms[ $term->term_id ] = $term->parent; } } elseif ( 'ids' == $_fields ) { - while ( $term = array_shift( $terms ) ) { + foreach ( $terms as $term ) { $_terms[] = $term->term_id; } } elseif ( 'names' == $_fields ) { - while ( $term = array_shift( $terms ) ) { + foreach ( $terms as $term ) { $_terms[] = $term->name; } } elseif ( 'id=>name' == $_fields ) { - while ( $term = array_shift( $terms ) ) { - $_terms[$term->term_id] = $term->name; + foreach ( $terms as $term ) { + $_terms[ $term->term_id ] = $term->name; } } elseif ( 'id=>slug' == $_fields ) { - while ( $term = array_shift( $terms ) ) { - $_terms[$term->term_id] = $term->slug; + foreach ( $terms as $term ) { + $_terms[ $term->term_id ] = $term->slug; } } diff --git a/wp-includes/version.php b/wp-includes/version.php index 11f1ad9bec..5807318907 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.2-alpha-31364'; +$wp_version = '4.2-alpha-31365'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.