Make WordPress Core

Changeset 35932


Ignore:
Timestamp:
12/14/2015 07:39:31 PM (11 years ago)
Author:
boonebgorges
Message:

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.

Merges [35931] to the 4.4 branch.

Props rogerhub.
Fixes #35025.

Location:
branches/4.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.4

  • branches/4.4/src/wp-includes/comment-template.php

    r35748 r35932  
    13311331        $comments_flat = array();
    13321332        foreach ( $_comments as $_comment ) {
    1333                 $comments_flat = array_merge( $comments_flat, array( $_comment ), $_comment->get_children( array(
     1333                $comments_flat[]  = $_comment;
     1334                $comment_children = $_comment->get_children( array(
    13341335                        'format' => 'flat',
    13351336                        'status' => $comment_args['status'],
    13361337                        'orderby' => $comment_args['orderby']
    1337                 ) ) );
     1338                ) );
     1339
     1340                foreach ( $comment_children as $comment_child ) {
     1341                        $comments_flat[] = $comment_child;
     1342                }
    13381343        }
    13391344
Note: See TracChangeset for help on using the changeset viewer.