Re: [PHP-DEV] Re: Poor date() performance (v 5.4.9) [PATCH]

2012-12-01 Thread Paul Taulborg
Submitted here: https://bugs.php.net/bug.php?id=63666

Also note that this can probably be back-ported into other 5.x
branches where this is applicable. I have only personally checked out
the latest release branch at this time.

Thanks!

On Sat, Dec 1, 2012 at 6:06 PM, Christopher Jones
 wrote:
>
>
> On 12/01/2012 10:21 AM, Paul Taulborg wrote:
>>
>>
>> [php_date.c patch]
>
>
> Thanks for the patch.  To ensure it isn't lost, can you open a bug at
> https://bugs.php.net/ and attach it?  And/or submit a pull request at
> https://github.com/php/php-src
>
> Regards,
>
> Chris
>
> --
> christopher.jo...@oracle.com
> http://twitter.com/ghrd

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Re: Poor date() performance (v 5.4.9) [PATCH]

2012-12-01 Thread Christopher Jones



On 12/01/2012 10:21 AM, Paul Taulborg wrote:


[php_date.c patch]


Thanks for the patch.  To ensure it isn't lost, can you open a bug at
https://bugs.php.net/ and attach it?  And/or submit a pull request at
https://github.com/php/php-src

Regards,

Chris

--
christopher.jo...@oracle.com
http://twitter.com/ghrd

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] Re: Poor date() performance (v 5.4.9) [PATCH]

2012-12-01 Thread Paul Taulborg

--- php-5.4.9_orig/ext/date/php_date.c  2012-11-20 23:12:20.0 -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;
-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-DEV] Re: Poor date() performance (v 5.4.9) [PATCH]

2012-12-01 Thread 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.0 -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;

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php