WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/07/2007 05:29:15 AM (14 years ago)
Author:
markjaquith
Message:

Use strpos instead of strstr where ever possible, for speed. Props rob1n. fixes #3920

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/formatting.php

    r4953 r4990  
    3030            // static strings
    3131            $curl = str_replace($static_characters, $static_replacements, $curl);
    32 
    3332            // regular expressions
    3433            $curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl);
    35         } elseif ( strstr($curl, '<code') || strstr($curl, '<pre') || strstr($curl, '<kbd') || strstr($curl, '<style') || strstr($curl, '<script') ) {
     34        } elseif (strpos($curl, '<code') !== false || strpos($curl, '<pre') !== false || strpos($curl, '<kbd') !== false || strpos($curl, '<style') !== false || strpos($curl, '<script') !== false) {
    3635            $next = false;
    3736        } else {
     
    7978    $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*<br />!', "$1", $pee);
    8079    $pee = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee);
    81     if ( strstr( $pee, '<pre' ) )
     80    if (strpos($pee, '<pre') !== false)
    8281        $pee = preg_replace('!(<pre.*?>)(.*?)</pre>!ise', " stripslashes('$1') .  stripslashes(clean_pre('$2'))  . '</pre>' ", $pee);
    8382    $pee = preg_replace( "|\n</p>$|", '</p>', $pee );
     
    659658function is_email($user_email) {
    660659    $chars = "/^([a-z0-9+_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,6}\$/i";
    661     if(strstr($user_email, '@') && strstr($user_email, '.')) {
     660    if (strpos($user_email, '@') !== false && strpos($user_email, '.') !== false) {
    662661        if (preg_match($chars, $user_email)) {
    663662            return true;
     
    10731072    $url = str_replace($strip, '', $url);
    10741073    $url = str_replace(';//', '://', $url);
    1075     $url = (!strstr($url, '://')) ? 'http://'.$url : $url;
     1074    $url = (strpos($url, '://') === false) ? 'http://'.$url : $url;
    10761075    $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&#038;$1', $url);
    10771076    if ( !is_array($protocols) )
Note: See TracChangeset for help on using the changeset viewer.