Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:27174 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 90112 invoked by uid 1010); 22 Dec 2006 05:07:20 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 90097 invoked from network); 22 Dec 2006 05:07:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Dec 2006 05:07:20 -0000 Authentication-Results: pb1.pair.com smtp.mail=php_lists@realplain.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=php_lists@realplain.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain realplain.com from 209.142.136.132 cause and error) X-PHP-List-Original-Sender: php_lists@realplain.com X-Host-Fingerprint: 209.142.136.132 msa2-mx.centurytel.net Linux 2.4/2.6 Received: from [209.142.136.132] ([209.142.136.132:55663] helo=msa2-mx.centurytel.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3E/72-04688-4E76B854 for ; Fri, 22 Dec 2006 00:07:19 -0500 Received: from pc1 (d35-28.rt-bras.wnvl.centurytel.net [69.179.162.28]) by msa2-mx.centurytel.net (8.13.6/8.13.6) with SMTP id kBM56eSU031690 for ; Thu, 21 Dec 2006 23:06:40 -0600 Message-ID: <00a901c72586$f7e7afb0$0201a8c0@pc1> To: Date: Thu, 21 Dec 2006 23:06:41 -0600 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_00A6_01C72554.AD0CDB50" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1807 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1896 Subject: [PATCH] Small date() optimization From: php_lists@realplain.com ("Matt Wilmas") ------=_NextPart_000_00A6_01C72554.AD0CDB50 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Hi, Just a simple patch for 5.2 to save smart_str_appends()'s strlen() calls in date_format(). It's already done in HEAD. Seems pretty safe for 5.2.1. :-) I also noticed that if the format string contains a backslash as the last character, it is lost (should be printed right?). So I changed that too and attached the patch for HEAD. 5.2's patch: http://realplain.com/php/date_optimization_5_2.diff Matt ------=_NextPart_000_00A6_01C72554.AD0CDB50 Content-Type: text/plain; name="date_backslash.diff.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="date_backslash.diff.txt" Index: ext/date/php_date.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /repository/php-src/ext/date/php_date.c,v=0A= retrieving revision 1.126=0A= diff -u -r1.126 php_date.c=0A= --- ext/date/php_date.c 11 Dec 2006 21:08:44 -0000 1.126=0A= +++ ext/date/php_date.c 22 Dec 2006 04:50:00 -0000=0A= @@ -926,7 +926,7 @@=0A= break;=0A= case 'U': length =3D date_spprintf(&buffer, 32 TSRMLS_CC, "%lld", = (timelib_sll) t->sse); break;=0A= =0A= - case '\\': if (i < format_len) i++; length =3D = date_spprintf(&buffer, 32 TSRMLS_CC, "%c", format[i]); break;=0A= + case '\\': if (i + 1 < format_len) i++; /* break intentionally = missing */=0A= =0A= default: length =3D date_spprintf(&buffer, 32 TSRMLS_CC, "%c", = format[i]);=0A= break;=0A= ------=_NextPart_000_00A6_01C72554.AD0CDB50--