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. git-svn-id: https://develop.svn.wordpress.org/trunk@35931 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
293de63969
commit
4732139799
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user