Some small tweaks to date_has_time and date_has_date to speed things up a bit.

Basically, return early when granularity isn't an array.

Second, use isset instead of array_intersect with count and a typecast.

I've included an XHProf showing the performance difference for date_has_time. A similar savings is gained from date_has_date.

Comments

minoroffense’s picture

StatusFileSize
new941 bytes

Patch with optimizations.

minoroffense’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 1933606-optimize-date_hast_time-date.patch, failed testing.