Make WordPress Core


Ignore:
Timestamp:
12/14/2015 07:36:05 PM (9 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.

Props rogerhub.
Fixes #35025.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment-template.php

    r35877 r35931  
    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.