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

git-svn-id: http://svn.automattic.com/wordpress/trunk@4990 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
markjaquith
2007-03-07 05:29:15 +00:00
parent 00f7071af4
commit 3320dd1380
26 changed files with 82 additions and 84 deletions

View File

@@ -1143,7 +1143,7 @@ function insert_with_markers( $filename, $marker, $insertion ) {
if ( $markerdata ) {
$state = true;
foreach ( $markerdata as $n => $markerline ) {
if ( strstr( $markerline, "# BEGIN {$marker}" ))
if (strpos($markerline, '# BEGIN ' . $marker) !== false)
$state = false;
if ( $state ) {
if ( $n + 1 < count( $markerdata ) )
@@ -1151,7 +1151,7 @@ function insert_with_markers( $filename, $marker, $insertion ) {
else
fwrite( $f, "{$markerline}" );
}
if ( strstr( $markerline, "# END {$marker}" ) ) {
if (strpos($markerline, '# END ' . $marker) !== false) {
fwrite( $f, "# BEGIN {$marker}\n" );
if ( is_array( $insertion ))
foreach ( $insertion as $insertline )
@@ -1189,11 +1189,11 @@ function extract_from_markers( $filename, $marker ) {
{
$state = false;
foreach ( $markerdata as $markerline ) {
if ( strstr( $markerline, "# END {$marker}" ))
if (strpos($markerline, '# END ' . $marker) !== false)
$state = false;
if ( $state )
$result[] = $markerline;
if ( strstr( $markerline, "# BEGIN {$marker}" ))
if (strpos($markerline, '# BEGIN ' . $marker) !== false)
$state = true;
}
}
@@ -1766,7 +1766,8 @@ function browse_happy() {
<p id="bh" style="text-align: center;"><a href="http://browsehappy.com/" title="'.$getit.'"><img src="images/browse-happy.gif" alt="Browse Happy" /></a></p>
';
}
if ( strstr( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ))
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)
add_action( 'admin_footer', 'browse_happy' );
function documentation_link( $for ) {
@@ -1927,11 +1928,11 @@ function wp_import_cleanup( $id ) {
function wp_import_upload_form( $action ) {
$size = strtolower( ini_get( 'upload_max_filesize' ) );
$bytes = 0;
if ( strstr( $size, 'k' ) )
if (strpos($size, 'k') !== false)
$bytes = $size * 1024;
if ( strstr( $size, 'm' ) )
if (strpos($size, 'm') !== false)
$bytes = $size * 1024 * 1024;
if ( strstr( $size, 'g' ) )
if (strpos($size, 'g') !== false)
$bytes = $size * 1024 * 1024 * 1024;
?>
<form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo $action ?>">