Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:71305 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 18842 invoked from network); 20 Jan 2014 08:05:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jan 2014 08:05:19 -0000 Authentication-Results: pb1.pair.com header.from=rasmus@lerdorf.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=rasmus@lerdorf.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lerdorf.com from 209.85.220.47 cause and error) X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 209.85.220.47 mail-pa0-f47.google.com Received: from [209.85.220.47] ([209.85.220.47:47126] helo=mail-pa0-f47.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5A/53-02192-DB8DCD25 for ; Mon, 20 Jan 2014 03:05:17 -0500 Received: by mail-pa0-f47.google.com with SMTP id kp14so6666552pab.6 for ; Mon, 20 Jan 2014 00:05:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type; bh=b3w1ifH4cHF6oX6lx41wb8Mo9JCcvKoFlCyL0H0YrSU=; b=i57ZkJGzFwNv6P7JRyIi+DpPTteLOiCNIdv3fYKvXtpVBInRzhGWx33Gv14XgSptZy UpOLLnT4ynn8P8wBKNmStvwWZShFjxczOEtCiR8gn4lvwKWF/B7WcATmACscBH6X/VTF ed7W10jA6UxAmK41okqkRxBRBK/RZ5U/rpt8efV3hLxIhd8gahDlCBqelBtOIFEAB8Qj kDDkwUCJ+t7Hbw8JoEfhKfXewnRE8s5NhJwwIxf4n9YTf5+Rmyrgha/19a8tMUP3q8Y0 CCPBKaOeRUrce7SgP+ldBZKokqYK8UcpakyZI7C5bdqn16g4baqzSoYbtaakegjlMfW2 Ttjw== X-Gm-Message-State: ALoCoQneOwkqesEj3ZSzww2FmmazuEH75FwHmUflwDBLKpIuWHoYwjbZ9NWyww1pZpogtAPlwoOb X-Received: by 10.66.158.132 with SMTP id wu4mr17309493pab.66.1390205114958; Mon, 20 Jan 2014 00:05:14 -0800 (PST) Received: from [192.168.200.30] (c-50-131-44-225.hsd1.ca.comcast.net. [50.131.44.225]) by mx.google.com with ESMTPSA id un5sm1253382pab.3.2014.01.20.00.05.13 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 20 Jan 2014 00:05:13 -0800 (PST) Message-ID: <52DCD8B5.6060006@lerdorf.com> Date: Mon, 20 Jan 2014 00:05:09 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: Patrick Schaaf , Larry Garfield CC: internals References: <004c01cf123d$35730870$a0591950$@tutteli.ch> <52D71748.1090402@googlemail.com> <52D71FAE.8030002@ajf.me> <005001cf124f$3a40df00$aec29d00$@tutteli.ch> <20140116110127.202079vzjsj76n7b@webmail.tutteli.ch> <0B.B1.24763.139B7D25@pb1.pair.com> <002001cf12da$2bfbda90$83f38fb0$@tutteli.ch> <52DCA3E7.80602@lerdorf.com> <52DCC067.9090603@garfieldtech.com> In-Reply-To: X-Enigmail-Version: 1.6 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="TRBuLVwnj9nJirKQGeRt6dSOOgVAHPL7A" Subject: Re: [PHP-DEV] Introducing "Array Of" RFC From: rasmus@lerdorf.com (Rasmus Lerdorf) --TRBuLVwnj9nJirKQGeRt6dSOOgVAHPL7A Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 1/19/14, 11:31 PM, Patrick Schaaf wrote: > Regarding the N*M checking complexity, couldn't a little bit of memory > alleviate the problem? >=20 > For each array, have a "member type" pointer, initially NULL. >=20 > When the member type needs to be checked for the first time, and that > "member type" pointer is not already set, do an O(N) scan of the arrray= , > testing compatibility of all members against the hinted type. Error on > mismatch, but when all members match, remember the type behind the "mem= ber > type" pointer. >=20 > When the member type needs to be checked and the "member type" pointer = _is_ > set, just compare it to the hinted type O(1). >=20 > There must be some overhead when elements are added to an array. Either= > "when member type is set, forget it", or even "when member type is alre= ady > set, check compatiility of the newly added element with the member type= , > and then remove member type on mismatch or keep it on match". This means every HT becomes larger now and every time you write to a HT you at the very least need to do one extra comparison. We use HTs everywhere, so this would have a performance impact on every script even if you have absolutely no intention of ever using this feature. -Rasmus --TRBuLVwnj9nJirKQGeRt6dSOOgVAHPL7A Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.22 (Darwin) Comment: GPGTools - https://gpgtools.org iEYEARECAAYFAlLc2LYACgkQlxayKTuqOuAt3ACfTOiymjmEnJTZCH0qftiuUscP PygAn3DdEK9mbcLtOr30spZOpMlTB7yP =VLfp -----END PGP SIGNATURE----- --TRBuLVwnj9nJirKQGeRt6dSOOgVAHPL7A--