cvs: pear /File_SearchReplace SearchReplace.php
| From: | anatoly techtonik | Date: | Fri, 11 Mar 2005 17:18:43 +0000 |
| Subject: | cvs: pear /File_SearchReplace SearchReplace.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-30211@lists.php.net to get a copy of this message | ||
techtonik Fri Mar 11 12:18:43 2005 EDT
Modified files:
/pear/File_SearchReplace SearchReplace.php
Log:
* Optimize memory usage in preg mode
http://cvs.php.net/diff.php/pear/File_SearchReplace/SearchReplace.php?r1=1.8&r2=1.9&ty=u
Index: pear/File_SearchReplace/SearchReplace.php
diff -u pear/File_SearchReplace/SearchReplace.php:1.8 pear/File_SearchReplace/SearchReplace.php:1.9
--- pear/File_SearchReplace/SearchReplace.php:1.8 Fri Mar 11 11:46:51 2005
+++ pear/File_SearchReplace/SearchReplace.php Fri Mar 11 12:18:43 2005
@@ -32,7 +32,7 @@
// | Author: Richard Heyes <richard@phpguru.org> |
// +-----------------------------------------------------------------------+
//
-// $Id: SearchReplace.php,v 1.8 2005/03/11 16:46:51 techtonik Exp $
+// $Id: SearchReplace.php,v 1.9 2005/03/11 17:18:43 techtonik Exp $
//
// Search and Replace Utility
//
@@ -368,7 +368,7 @@
clearstatcache();
$file = fread($fp = fopen($filename, 'r'), filesize($filename));
fclose($fp);
- $occurences = count($matches = preg_split($this->find, $file)) - 1;
+ $occurences = preg_match_all($this->find, $file, $matches);
$file = preg_replace($this->find, $this->replace, $file);
if ($occurences > 0) $return = array($occurences, $file); else $return = FALSE;