[Patch] Use str_replace instead of preg_replace in Net_SMTP/SMTP.php
| From: | Matthias Pigulla | Date: | Sun, 19 Sep 2004 14:53:53 +0000 |
| Subject: | [Patch] Use str_replace instead of preg_replace in Net_SMTP/SMTP.php | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-33447@lists.php.net to get a copy of this message | ||
Hi all,
this patch will substitute two preg_replaces in SMTP.php with
str_replace. That's not a big change; however, as all data sent passes
through these calls, it makes a performance difference - at least for me
;)
Best regards,
Matthias
Index: SMTP.php =================================================================== RCS file: /repository/pear/Net_SMTP/SMTP.php,v retrieving revision 1.47 diff -u -r1.47 SMTP.php --- SMTP.php 26 Apr 2004 23:00:28 -0000 1.47 +++ SMTP.php 19 Sep 2004 14:43:50 -0000 @@ -735,14 +735,14 @@ * Change Unix (\n) and Mac (\r) linefeeds into Internet-standard CRLF * (\r\n) linefeeds. */ - $data = preg_replace("/([^\r]{1})\n/", "\\1\r\n", $data); - $data = preg_replace("/\n\n/", "\n\r\n", $data); + $data = str_replace("\r\r\n", "\r\n", str_replace("\n", "\r\n", $data)); /* * Because a single leading period (.) signifies an end to the data, * legitimate leading periods need to be "doubled" (e.g. '..'). */ - $data = preg_replace("/\n\./", "\n..", $data); + $data = str_replace("\n.", "\n..", $data); + } /**
Index: SMTP.php =================================================================== RCS file: /repository/pear/Net_SMTP/SMTP.php,v retrieving revision 1.47 diff -u -r1.47 SMTP.php --- SMTP.php 26 Apr 2004 23:00:28 -0000 1.47 +++ SMTP.php 19 Sep 2004 14:43:50 -0000 @@ -735,14 +735,14 @@ * Change Unix (\n) and Mac (\r) linefeeds into Internet-standard CRLF * (\r\n) linefeeds. */ - $data = preg_replace("/([^\r]{1})\n/", "\\1\r\n", $data); - $data = preg_replace("/\n\n/", "\n\r\n", $data); + $data = str_replace("\r\r\n", "\r\n", str_replace("\n", "\r\n", $data)); /* * Because a single leading period (.) signifies an end to the data, * legitimate leading periods need to be "doubled" (e.g. '..'). */ - $data = preg_replace("/\n\./", "\n..", $data); + $data = str_replace("\n.", "\n..", $data); + } /**