WordPress.org

Make WordPress Core

Ticket #6877: 6877.2.diff

File 6877.2.diff, 1.0 KB (added by azaozz, 11 years ago)

After chatting with Ryan, cleaned up the preg_split a bit. Makes it a little faster for very large posts.

  • wp-includes/formatting.php

     
    126126                $pee = preg_replace('|\s*</embed>\s*|', '</embed>', $pee);
    127127        }
    128128        $pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates
    129         $pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end
     129        //$pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end
     130        $pees = preg_split('/\n\s*\n/', $pee, -1, PREG_SPLIT_NO_EMPTY);
     131        $pee = '';
     132        foreach ( $pees as $tinkle )
     133                $pee .= '<p>' . trim($tinkle, "\n") . "</p>\n";
    130134        $pee = preg_replace('|<p>\s*?</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace
    131135        $pee = preg_replace('!<p>([^<]+)\s*?(</(?:div|address|form)[^>]*>)!', "<p>$1</p>$2", $pee);
    132136        $pee = preg_replace( '|<p>|', "$1<p>", $pee );