Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105152 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 82821 invoked from network); 8 Apr 2019 19:58:56 -0000 Received: from unknown (HELO localhost.localdomain) (76.75.200.58) by pb1.pair.com with SMTP; 8 Apr 2019 19:58:56 -0000 To: internals@lists.php.net References: <20190405072630.E2A025FB14@mx.zeyos.com> Date: Mon, 8 Apr 2019 18:55:36 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:52.0) Gecko/20100101 Firefox/52.0 SeaMonkey/2.49.2 MIME-Version: 1.0 In-Reply-To: <20190405072630.E2A025FB14@mx.zeyos.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 176.10.220.178 Subject: Re: Optimize zend_string equality check with hash key From: ajf@ajf.me (Andrea Faulds) Message-ID: Hi Benjamin, Benjamin Coutu wrote: > if (ZSTR_H(s1) && ZSTR_H(s1) != ZSTR_H(s2)) { > return 0; > } Should that not be like this?: if (ZSTR_H(s1) && ZSTR_H(s2) && ZSTR_H(s1) != ZSTR_H(s2)) { It would be possible the other string also has no hash value. Otherwise this sounds sensible to me, but it is also so obvious that I was assuming until now that PHP does it, so maybe someone else knows a reason why we don't? (Maybe it's just not worth the extra branches?) Thanks, Andrea