Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64129 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 75914 invoked from network); 1 Dec 2012 18:17:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Dec 2012 18:17:14 -0000 Authentication-Results: pb1.pair.com header.from=njaguar@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=njaguar@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.170 as permitted sender) X-PHP-List-Original-Sender: njaguar@gmail.com X-Host-Fingerprint: 209.85.214.170 mail-ob0-f170.google.com Received: from [209.85.214.170] ([209.85.214.170:52169] helo=mail-ob0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FA/14-26487-9A94AB05 for ; Sat, 01 Dec 2012 13:17:14 -0500 Received: by mail-ob0-f170.google.com with SMTP id wp18so1406115obc.29 for ; Sat, 01 Dec 2012 10:17:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=3qt8FjeOvvUKeSI2YB2+ZCqvMbV+eeN4lf3+uwQUh7s=; b=A/jTHEtYHYrUinTfh6WlXSIGIPYmoj2RVEGUsvkOuHfxDE34Asy03GQo3Pr1A7eury Y95Dfnlr38XinjcmsgRi6DA0W2PdGqOk0oISrcQgTbtbva8stjF2uZ8JR/yNDZzW70E5 HKODV8n8OKuFSuP0cu0Qv94ylS6C2P6+KulQr6Lzme6rzkGdZPjgMUkzf8nvZZjTJ8Dw +3XPL/Iv6S85EGuI1JkJNbAbT4/8tKZuWDXVRQ7FPoN2Wfapj6X6UgCYVXX3s19I9Kn/ VgWHKgkHIfrVvUvLxl5z5NSHd+NSObARTe3+o3piLnf7Yd4md1O+XeHqs+nNLJwCFp0B I2Vg== MIME-Version: 1.0 Received: by 10.60.1.169 with SMTP id 9mr4310727oen.93.1354385831651; Sat, 01 Dec 2012 10:17:11 -0800 (PST) Received: by 10.182.89.66 with HTTP; Sat, 1 Dec 2012 10:17:11 -0800 (PST) In-Reply-To: References: Date: Sat, 1 Dec 2012 12:17:11 -0600 Message-ID: To: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: Poor date() performance (v 5.4.9) [PATCH] From: njaguar@gmail.com (Paul Taulborg) My apologies, pasting the patch in directly: --- php-5.4.9_orig/ext/date/php_date.c 2012-11-20 23:12:20.000000000 -0600 +++ php-5.4.9/ext/date/php_date.c 2012-12-01 05:38:22.136264276 -0600 @@ -948,6 +948,7 @@ timelib_time_offset *offset = NULL; timelib_sll isoweek, isoyear; int rfc_colon; + char weekYearSet = 0; if (!format_len) { return estrdup(""); @@ -974,7 +975,6 @@ offset = timelib_get_time_zone_info(t->sse, t->tz_info); } } - timelib_isoweek_from_date(t->y, t->m, t->d, &isoweek, &isoyear); for (i = 0; i < format_len; i++) { rfc_colon = 0; @@ -990,8 +990,12 @@ case 'z': length = slprintf(buffer, 32, "%d", (int) timelib_day_of_year(t->y, t->m, t->d)); break; /* week */ - case 'W': length = slprintf(buffer, 32, "%02d", (int) isoweek); break; /* iso weeknr */ - case 'o': length = slprintf(buffer, 32, "%d", (int) isoyear); break; /* iso year */ + case 'W': + if(!weekYearSet) { timelib_isoweek_from_date(t->y, t->m, t->d, &isoweek, &isoyear); weekYearSet = 1; } + length = slprintf(buffer, 32, "%02d", (int) isoweek); break; /* iso weeknr */ + case 'o': + if(!weekYearSet) { timelib_isoweek_from_date(t->y, t->m, t->d, &isoweek, &isoyear); weekYearSet = 1; } + length = slprintf(buffer, 32, "%d", (int) isoyear); break; /* iso year */ /* month */ case 'F': length = slprintf(buffer, 32, "%s", mon_full_names[t->m - 1]); break;