Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116093 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 28471 invoked from network); 18 Sep 2021 22:46:14 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 18 Sep 2021 22:46:14 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 981A31804B2 for ; Sat, 18 Sep 2021 16:26:33 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_HOTMAIL_RCVD2, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,YOU_INHERIT autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8075 40.80.0.0/12 X-Spam-Virus: No X-Envelope-From: Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12olkn2103.outbound.protection.outlook.com [40.92.23.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 18 Sep 2021 16:26:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D32HzJQ/4koYJKWSJ3p7bSvL770nqNa+ftEuZD23vltQSJGYndIvpcNVgqyoASrolF9uXvRpA7p5AIztMOGXKXX0MsL9klX/EyjAgakwfThTjahpFXXrgi+7T3Cp3K5Oa6sXSqKRKQ6vvRqa2jYgJy9ILrqRFzaS7d+iVQC/FDOrTdkBs99xZbMjOJcpJT8C0Ghdw+xHzGTwt3exjoJdzMf6nTzTi6uxDEQIMNnH7+sx4tchbyByaahdl0cT+nv/9vVmRMnFZtkilQ9tQxTB3T87jzSdmPqJgTms8X70kjkLSS+vdumllzmtGTqRJ957TVmhVy0MXNIMagLylxmSKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Mj5/bGtVuz0fhJFCdgm12WrepMn9MHmZEMmeGyYZowg=; b=MxgniLxE/d1qEEQ4EHK947Oq018LW1BD+0KPPNUxdTL2+/+IgjgezmRWUo0/w1m5nzcOHx+aWdEePn+pXm2WLPrZCjvbvoHEj4qVHqVsy3AilmQ5KovcPGdn7UnDmJNlYr+NUYef+Z1+ITQwZIe+7IkxGjfCQdJ8aMtdGDijnHIj0Q3Rjnoln9hoak+0F15tlqWZg5jck0YTvEJqQBf27yl37LvLPU1G/99KRoByRW4uWMFZBgClHosUES+GUsZ8Uh6J2y+Gq22vIwoPArY32rQ5EiW2ZsovVRVQ++Llxv3Y19sOidT5IUMf20Bx+LVaWahNqg9kZUnJC9+5gYoVLw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Mj5/bGtVuz0fhJFCdgm12WrepMn9MHmZEMmeGyYZowg=; b=Fvf2/GLUrdaSV6yRq7Wj9ydPCBaV3HmwXNj2w/33rS9TWS5NxN9BHATRQPLc3B3zRu6NCGI7dGCXoe7Ypv/bu4rTDfaK/H7z/pbrpsm+EnyxJ0iIRxcoLZrM5rFVrRyU/+GDxWDm2W37aBknHzRv5X1/sK+HcoxRrNRo6FX8B0Ku4VfPw9NHsbn8APJAfRDCIR1/W0zaMt+plCG5PxFzzCbYQ0pmY6O6Td46QYYsckCoH4nvlHiYuvobSQNyLly9ZWeX+mUUdoMHKzhWwIeMlRvYDtiZuAhViDZXDAK8eqYDH9v1GV0T+vOsfkq+TxvBhu7plYe0i8ID5V2vgJtPMw== Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2603:10b6:5:1cf::26) by DM5PR07MB3866.namprd07.prod.outlook.com (2603:10b6:3:e9::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.18; Sat, 18 Sep 2021 23:26:31 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::7181:60db:c4d2:835]) by DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::7181:60db:c4d2:835%7]) with mapi id 15.20.4523.018; Sat, 18 Sep 2021 23:26:31 +0000 To: "internals@lists.php.net" Thread-Topic: [PHP-DEV] RFC: Add `final class Vector` to PHP Thread-Index: AQHXq2Dr5ROExEhu802SAlX6zd1M+6upRoIAgAEp0s0= Date: Sat, 18 Sep 2021 23:26:31 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: suggested_attachment_session_id: 04900e78-9380-b1a2-e9a1-8d3d5c14ff00 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [CKP2HQc9sEtScHqaEvc48uUQz/1gIqBgMRb3FpaSCP1rzt2fVc9bHpfPT0zIXf9Qlu182qpPnvM=] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 3757897d-89b7-488b-f4a1-08d97afbbf54 x-ms-traffictypediagnostic: DM5PR07MB3866: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: x2TQFLsx3407C5m0TBd46VpOEZm2d4WbT7G0DTqlb+rOShcHWSuDcsAy9Th8D7l7BWRDymkgOtbGSCjwlpYo7sgCZk0Xr9vWALVHlA+D46dy34WBFJBTISqejLTJFGTheDCneq4QTVTvQHH/WPqerB1DYkqYEGvbyi0s93qG5hgfCLW/a+e64VIzUGFk0W41M9FPMItmOaVLlm7dwi2tpcAdNQqhkQTBZTAdOSkPeYPtAljTgFvnN2+xFah6Vv0uGTTUtD4qGZi9E8rW7v1KS56kAl29pxtv2zSofDo+fQV5sJDW1T3/W2ze3rUZghg5jkd49fA8+veMv+p/xf9iRFVXCaPWQ8AGDa0GtN1FR+EprKVkGmTT/m1sHgHx2ABiDt+f4vc0qSv0jTJ5NkBykqRTq0w4s24R1LGDzaF88y7atlI3T38zXd71aVRb4MGe x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: VoKVGsBA84BIpONWiRx5PX0LANumR4flE/+RN0Hrsy38Wdgzb3OKGWS+RGpILTMHJfG8r/tcIfWJOCQWXuldjd+Tkx7Vvw1/wkWlPuGWLEQB7fgIIkziHfGWDpwOOgt0Ye+j8bS4E78T2RbxgnuYf7GI7fe1YLxaCPUr/6aykxul5qGqLSPJ3BKsnJy1vQyRzPQAkOkfzFhHWGXH12aXbw== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: sct-15-20-3174-20-msonline-outlook-35401.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR07MB6618.namprd07.prod.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 3757897d-89b7-488b-f4a1-08d97afbbf54 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2021 23:26:31.4801 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR07MB3866 Subject: Re: [PHP-DEV] RFC: Add `final class Vector` to PHP From: tysonandre775@hotmail.com (tyson andre) Hi Mike Schinkel,=0A= =0A= > Given there seems to be a lot of concern about the approach the RFC propo= ses would it not address the concerns about memory usage and performance if= several methods were added to SplFixedArray instead (as well as functions = like indexOf(), contains(), map(), filter(), JSONSerialize(), etc., or simi= lar):=0A= > =0A= > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= > =0A= > setCapacity(int) =97 Sets the Capacity, i.e. the maximum Size before resi= ze=0A= > getCapacity():int =97 Gets the current Capacity.=0A= > =0A= > setGrowthFactor(float) =97 Sets the Growth Factor for push(). Defaults to= 2=0A= > getGrowthFactor():float =97 Gets the current Growth Factor=0A= > =0A= > pop([shrink]):mixed =97 Returns [Size] then subtracts 1 from Size. If (bo= ol)shrink passed then call shrink().=0A= > push(mixed) =97 Sets [Size]=3Dmixed, then Size++, unless Size=3DCapacity = then setSize(n) where n=3Dround(Size*GrowthFactor,0) before Size++.=0A= > =0A= > grow([new_capacity]) =97 Increases memory allocated. Sets Capacity to Siz= e*GrowthFactor or new_capacity.=0A= > shrink([new_capacity]) =97 Reduces memory allocated. Sets Capacity to cur= rent Size or new_capacity.=0A= > =0A= > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= > =0A= > If you had these methods then I think you would get the memory and perfor= mance improvements you want, and if you really want a final Vector class fo= r your own uses you could roll your own using inheritance or containment.= =0A= =0A= I asked 8 months ago about `push`/`pop` in SplFixedArray. The few responses= were unanimously opposed to SplFixedArray being repurposed like a vector,= =0A= the setSize functionality was treated more like an escape hatch and it was = conceptually for fixed-size data.=0A= =0A= I also believe adding a configurable growth factor would be excessive for a= high level language.=0A= =0A= Thanks,=0A= Tyson=0A=