From b6dbe1cea94857c7cb8d4e1d682dcac83b74aade Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Mon, 14 Dec 2015 19:37:43 +0000 Subject: [PATCH] Don't use `array_merge()` when building comment children arrays. `array_merge()` is much slower than building the combined array using a `foreach` loop. The performance difference was causing a speed regression with the `get_children()` functionality introduced in 4.4. Props rogerhub. Fixes #35025. Built from https://develop.svn.wordpress.org/trunk@35931 git-svn-id: http://core.svn.wordpress.org/trunk@35895 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/comment-template.php | 9 +++++++-- wp-includes/version.php | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php index 13d34a5555..854cbe73b3 100644 --- a/wp-includes/comment-template.php +++ b/wp-includes/comment-template.php @@ -1330,11 +1330,16 @@ function comments_template( $file = '/comments.php', $separate_comments = false // Trees must be flattened before they're passed to the walker. $comments_flat = array(); foreach ( $_comments as $_comment ) { - $comments_flat = array_merge( $comments_flat, array( $_comment ), $_comment->get_children( array( + $comments_flat[] = $_comment; + $comment_children = $_comment->get_children( array( 'format' => 'flat', 'status' => $comment_args['status'], 'orderby' => $comment_args['orderby'] - ) ) ); + ) ); + + foreach ( $comment_children as $comment_child ) { + $comments_flat[] = $comment_child; + } } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index b145c8345c..95626d63cb 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.5-alpha-35930'; +$wp_version = '4.5-alpha-35931'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.