Ver Fonte

Avoid preg_replace for simple cases

Use the faster str_replace() and str_ireplace() instead.
From http://www.php.net/manual/function.str-replace.php : "If you don't
need fancy replacing rules (like regular expressions), you should always
use this function instead of preg_replace(). "
Alexandre Alapetite há 12 anos atrás
pai
commit
f2697be658
3 ficheiros alterados com 3 adições e 3 exclusões
  1. 1 1
      app/models/Feed.php
  2. 1 1
      app/views/entry/bookmark.phtml
  3. 1 1
      app/views/entry/read.phtml

+ 1 - 1
app/models/Feed.php

@@ -172,7 +172,7 @@ class Feed extends Model {
 				);
 			} else {
 				$feed = new SimplePie ();
-				$url = preg_replace ('/&/', '&', $this->url);
+				$url = str_replace ('&', '&', $this->url);
 				if ($this->httpAuth != '') {
 					$url = preg_replace ('#((.+)://)(.+)#', '${1}' . $this->httpAuth . '@${3}', $url);
 				}

+ 1 - 1
app/views/entry/bookmark.phtml

@@ -12,4 +12,4 @@ $url = Url::display (array (
 	'params' => Request::params (),
 ));
 
-echo json_encode (array ('url' => preg_replace ('#&#i', '&', $url)));
+echo json_encode (array ('url' => str_ireplace ('&', '&', $url)));

+ 1 - 1
app/views/entry/read.phtml

@@ -12,4 +12,4 @@ $url = Url::display (array (
 	'params' => Request::params (),
 ));
 
-echo json_encode (array ('url' => preg_replace ('#&#i', '&', $url)));
+echo json_encode (array ('url' => str_ireplace ('&', '&', $url)));