Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119556 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 35391 invoked from network); 15 Feb 2023 07:02:30 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 15 Feb 2023 07:02:30 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 324EE180083 for ; Tue, 14 Feb 2023 23:02:28 -0800 (PST) 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.2 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 14 Feb 2023 23:02:27 -0800 (PST) Received: by mail-wm1-f51.google.com with SMTP id j32-20020a05600c1c2000b003dc4fd6e61dso736028wms.5 for ; Tue, 14 Feb 2023 23:02:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:references :in-reply-to:user-agent:subject:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=zJNJA9A5CpSqppPNFOFZPKgjryU4etl9UBjxAXWHA3w=; b=g6bWae2Vd0cWAI2Vy4urAfdWV3aGlnkK7/NMkGcX2Oc35tZI8ZQcdaBgzqoi8Kugk4 go7b5RtG1+lIoAa+m3AxEvLwr0qJbCpKIIN6rPMmlHkcPihVuCrQgjQqXTbR2fU41DLg v/81PeVzfw8a2whwTqzSRi1HwmWJCB4rKSE+i9zst7bE+gIgpIPkT/VWUHtiDB16Xfm/ 6Lav924Gofdg7Ti0j5uHb/omqgtjzWhFDppmeq+ezikJE7ksTsSo9GFYsPhOJD7u8E+u mGxyIX4H9F71QL1qAzKFAzZoGpxMLxXBPBqOFChmf+oDiCH9+wkyWr35OSAReY37RXFT XTSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:references :in-reply-to:user-agent:subject:to:from:date:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=zJNJA9A5CpSqppPNFOFZPKgjryU4etl9UBjxAXWHA3w=; b=YIxuOdCPza6XxyJaHFjTSWP2kzNMsQfis4L/1jpKWyH5t3hKP+iKiRqHfL3+7yR7K4 duAW31+tjgJ5kdTIHgMQZyplmAStky4RPWEe0aO/6B8jTV9zdmOGN9SyFek0YlOrBK2N Qb+ewwQ2FfY54Y74X7jAkyZ0vF647v9Xjt31uAv7jCNZhXv6D2O4x/JqSxBHO9OeLVif DaMpy2MzuQMWM4G2hyNtyq2w/HspkJNuCXYhrZGy+nWf4C2YKVZc3Fq4k/iFTWte/CZN PPpHyEF0Ck0RGniYJqVRZ1ehW24GextlUltNHqR5lvB4HV3FjkAp7z9PffL0BfTFKy/R 72WA== X-Gm-Message-State: AO0yUKWn0MmFn8R9wS7wz0VMsJXH7CL9nwq7hfTtiAEG6OJ42z4G9N5c S+RNfR0Kb620CRXZJfCPYOA1pPZl5hU= X-Google-Smtp-Source: AK7set+XJJKWSXP8FGpFoGQtc1RRMEbgVHNdIXPbDwhlIEXgPgyZd2FSdyIZZP5qZAIpmmKebA7Hew== X-Received: by 2002:a05:600c:1c9a:b0:3df:fc69:e96b with SMTP id k26-20020a05600c1c9a00b003dffc69e96bmr1156698wms.5.1676444546346; Tue, 14 Feb 2023 23:02:26 -0800 (PST) Received: from [127.0.0.1] (92.40.197.221.threembb.co.uk. [92.40.197.221]) by smtp.gmail.com with ESMTPSA id l18-20020a5d6752000000b002c5503a8d21sm9847500wrw.70.2023.02.14.23.02.24 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Feb 2023 23:02:25 -0800 (PST) Date: Wed, 15 Feb 2023 07:02:23 +0000 To: internals@lists.php.net User-Agent: K-9 Mail for Android In-Reply-To: References: <92c4514f-70e3-75c9-7084-9e29641e25e7@gmail.com> <7e86a2d2-b971-592c-64e3-e86c13b5be80@cubiclesoft.com> Message-ID: <84204896-F9CE-4186-8A72-573A0B46FC1D@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Working With Substrings From: rowan.collins@gmail.com (Rowan Tommins) On 15 February 2023 05:18:50 GMT, Rowan Tommins wrote: >My instinct was that it could just be a built-in class, with an internal = pointer to a zend_string that's completely invisible to userland=2E Somethi= ng like how the SimpleXML and DOM objects just point into a libxml parse re= sult=2E To make this a bit more concrete, what I was picturing was that instead of= this example: str_splice($this->pagemap[$pagepos][0], $x2, $size2, $data, $x, $size); You would have something like this: // Wrap an existing zend_string in an object $destBuffer =3D Buffer:: fromString($this->pagemap[$pagepos][0]); // Similar, but also track start and end offsets $sourceBuffer =3D Buffer::fromSubString($data, $x, $size); // Now do the actual memory copy $destBuffer->splice($x2, $size2, $sourceBuffer); The explicit size handling parameters of str_splice, and the str_realloc f= unction, would be replaced with methods to get and set the allocated length= of a Buffer object=2E The buffer would only be shrunk when requested, or w= hen cast to string=2E The $src_repeat argument feels somewhat out of place in a "splice" operati= on anyway, and perhaps should be part of a different method=2E On a different note, don't forget that we have named parameters now, which= is a big help with signatures like this; this example: $vsize =3D str_splice($str, $pos, $pos2 - $pos + 1, $embed, 0, null, 1, fa= lse, $vsize); Looks slightly less scary written like this: $vsize =3D str_splice($str, $pos, $pos2 - $pos + 1, $embed, shrink: false,= dst_lastsize: $vsize); Regards, --=20 Rowan Tommins [IMSoP]