Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102010 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15460 invoked from network); 30 Mar 2018 14:11:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Mar 2018 14:11:13 -0000 Authentication-Results: pb1.pair.com header.from=cmbecker69@gmx.de; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=cmbecker69@gmx.de; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmx.de designates 212.227.17.22 as permitted sender) X-PHP-List-Original-Sender: cmbecker69@gmx.de X-Host-Fingerprint: 212.227.17.22 mout.gmx.net Received: from [212.227.17.22] ([212.227.17.22:48879] helo=mout.gmx.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 74/60-06325-D754EBA5 for ; Fri, 30 Mar 2018 09:11:11 -0500 Received: from [192.168.2.109] ([91.8.175.66]) by mail.gmx.com (mrgmx103 [212.227.17.168]) with ESMTPSA (Nemesis) id 0MDi9C-1ekvJF2TaY-00H3qh; Fri, 30 Mar 2018 16:10:11 +0200 To: Benjamin Coutu , PHP Internals Cc: Nikita Popov , Fleshgrinder References: <20180329095120.C8C0D5FB03@mx.zeyos.com> Message-ID: <9fcd519c-8a83-cb22-eeb3-e8d7aa9bc72e@gmx.de> Date: Fri, 30 Mar 2018 16:10:10 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180329095120.C8C0D5FB03@mx.zeyos.com> Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:ChLjynt2zsa/JHzRf9iAOc64Jsg28gaRbL/wNh2kEFyZdDGKj3P iR/liD5Tv2CHVxHNRxDCzS1FrWKIa4uNzGP236zQx963JSxFjLE3XrLA2w1VhYIuDAXBTnD RYi7LBbLCGNN+MoTmQp+d2qRCMR9RnX036Qj8QMP9pfDqX6dKSghwIKrbgWg4YuriDMr1in pNmzbEkjW0gojS+m0yyCg== X-UI-Out-Filterresults: notjunk:1;V01:K0:kHlUR3XM+R8=:x/2UqWw+p4MhPcitvmmHSE MzuqvhInstRaWSJkgX3uzINIuIb7q3bXwnKI10LRSFM5kBeTJljvkvvoF7zh1efzMxYRgchLR BcZrSn0b0TrraVBS6Ltr0qql1kwO8DTEcI5GlIjbbi86bON1XaHGTl3hDI34/pt3IfkXj0npU UaocP5VljZk72R7Zw3oFy+LiLLY8KDc/iGOM/phsntz8HQEANVXoHGCrcKKbh1obMVloBkOyc t/d9HnQTQz6IShF+i+CScONKPKJwS1fCBlLnCifC1GAuzz/YnfSR/d6mOs7F+2cPonma79dfm Cbc8G+O0ixxTcBTmWip/mYwIhQ2EC08EnOV/YjB8UqfNekpxoQ0QMBRM5uYhhy2MU0s++x3ls BQbKbu1VfPuCLmLg1eAO4H4RNSnHGW77uEqBwA3ZIpOfAf4NCiRlI6QonCqu5ztcLa1Kt6ss8 ldR18Sa8IPrIAgTv9FvIuT+dp4oZZCuCOKnaZWeYxk2Km6OZ/NeD8vX7stSNTNgg6zjgtct3o e2xr+LKi5iK6ELmutfn4Kzo9+47ihPltuooxdUNXftgeJwogCdYh7TfFADCnCuRuhe56WXTzN ZRmFmhKgaSvuUWzWZtFD7STWM6TAxjDpChhHJN0wIkBMBQNvW80gm8gjnIP6fvzruTsmK0m8s DYmY+AB9wfmzqI6oCbX/DiOIr6zn2FKnQy/h6Zx264jr+fvC3//uqpnRVLp+Az1ugFXAVMdIs wVdfOwpARiByfa+du++YTrSXJb8U0nAFFU2f0NSDnapmXhGs5utRHHC/TxawEkqeReSizq/CN GKjG7jNu4fAow9Iy3X+ZQuGuvV9CX1jfadJrKtrm4XueARndio= Subject: Re: Unnecessary overhead in getdate() From: cmbecker69@gmx.de ("Christoph M. Becker") On 29.03.2018 at 11:51, Benjamin Coutu wrote: > Just like `[i]date()`, `getdate()` without the `$timestamp` argument uses the current timestamp. > > The code for `[i]date()` (https://github.com/php/php-src/blob/master/ext/date/php_date.c#L1276) only makes a system call to `time(NULL)` when the `$timestamp` argument is missing. In contrast `getdate()` (https://github.com/php/php-src/blob/master/ext/date/php_date.c#L1828) always performs a system call to `time(NULL)` even if `$timestamp` is supplied by the user. > > The code for `getdate()` should mimic what is done for `date()` to avoid unnecessary system call overhead, hence only call `time(NULL)` when `!ZEND_NUM_ARGS()`. ACK. I wonder, though, whether it is safe to convert a `time_t` (which is supposed to be returned by `time()`) to `zend_long`. POSIX 6 claims that `time_t` shall be an integer or real-floating type[1]; POSIX 7 is more specific ("time_t shall be an integer type")[2], but obviously there are neither guarantees regarding signess nor size, and it doesn't seem that we have respective checks in place[3]. [1] [2] [3] -- Christoph M. Becker