Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124238 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 421561A009C for ; Sat, 6 Jul 2024 01:22:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1720229027; bh=VYXNgSLWCekFelGQyC0qfqscfZMPcyG5Idku0iWlKMY=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=IPvVNSohtyBfr9IeT4C/2C1n+XZoy+Ah6kL3Nc7rbNg2iK3Ycmmdsdq7FI+sDyOUO W924DaDO95AZS+/ngu4a/mxqW5dTbmWGDrX8fvsNPLk1iyujrjWyalFz+MFW+2hdo8 uIesQoJuKtYPj/3LNnm2dQvghUsxOS0VfSftPZ7as0+KnX/1BlPWlygrnes8zjbJZV e8zvT9i23KithSN8QHGzZjiHxArb36zJZMX6ZNIpPdvi7iA+N/FEypoIxm3L0TNgPA yMPYN2a7ff99QxNT97mPa5eJvaJzrE0rMCgREyhrlkQTUzfFCh/OCFWuMeaRH2WDdV tEr96r+ot5a8A== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5C30A18005F for ; Sat, 6 Jul 2024 01:23:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DMARC_MISSING,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 6 Jul 2024 01:23:45 +0000 (UTC) Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-6512866fa87so20694057b3.2 for ; Fri, 05 Jul 2024 18:22:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20230601.gappssmtp.com; s=20230601; t=1720228942; x=1720833742; darn=lists.php.net; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=vhapW06GXXWqPTjrdetMKtd983RUnI7KPbOS6lI2/f0=; b=mSd+8Pb+KlLonisi+rcxaq+TOZlWtGZYT/hYWdbZyFGiSAtSmmh0tl+ty1+ksf/qm0 aEbOx1i7ArJvVY+rWtPGKraigC5h3zkr+6hJ8ra7SvlHT360SwNvRBgEWitbMC10bNb5 vmbYQbtH2/VSd/dTRgsnAhLKLOUnZ1UQAmh3E+P6Qeh3XnHzhD2GL30NzFZkzXa0gvT5 DFasNHPvzLlJaGn54ADrLHI13Yf5uCok+0KFyutP//QokjE7o96nQ5eYwoy3lcXNtQBW jrzu+ZBRT5EQfJ0GGD4KtN6gE3XfmaOExg1Bd+HRtU72Bf5JqT5YwqKLpql5kV360sZm NCFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720228942; x=1720833742; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vhapW06GXXWqPTjrdetMKtd983RUnI7KPbOS6lI2/f0=; b=OE87bAO1wDBj8aBOAKJY+k6QabDvSDQIHxInAoQ5vAA43r6oLLfDdp8izs27oL+nkS QUmqkDIercL/sMfGpBwRc6/Fyz8FMUgkxKKIcmJQpDqUT3CaQEFuBs6+nKGO4yJYEm5y qIWkBfFAbMRFntko3l/n46Fmn9EgtmxyNGk+mtfdexYjE+hC/qmm/la4pVy1Z5kAghNN iOo55c/fEBJQOVSfWGNIMxNK9M/o6Jyv8iirTtTCfl3tE/RE+jSd3XJo7405GHOYG0m6 HkRLFFF+pVasnMJQceQnrk3wx/OE3twdUIe29nCMQN0IQoG1G2M+XbQDHuaZLEcMk/cc zYrQ== X-Forwarded-Encrypted: i=1; AJvYcCXwkT3Xs0Ymvt4QPFq47fDvD0YsMZvGXIV2dRsMLsbjRTfwTnP/wIgJwMNNdR4BBfIBzFwNEyfxqr7wNesx3rIHJ2bNe9rIXw== X-Gm-Message-State: AOJu0YzhPmgkZcCTp1q434N7bNUONraP+1Wlgbmc7jYlaK8FTAvsQ1cD Crkpl6vU4/xI5qucfU2vl9F3lk9eJeNThwQgazh/XbTk5Uy4QHDTq7kA/7VE+N5f2d8iaEdkaIq Fpps= X-Google-Smtp-Source: AGHT+IE1CmnB3yUr9deBPOJiWp7qY2Jalwbe0tKHk8pSFUqtnrc+wFBqNOtBoKm0yOMSQnD2ZkgV7g== X-Received: by 2002:a81:9104:0:b0:64b:77e:84cf with SMTP id 00721157ae682-652d853645bmr57818377b3.43.1720228941754; Fri, 05 Jul 2024 18:22:21 -0700 (PDT) Received: from smtpclient.apple (c-98-252-216-111.hsd1.ga.comcast.net. [98.252.216.111]) by smtp.gmail.com with ESMTPSA id 00721157ae682-64a9bf32b76sm30063857b3.109.2024.07.05.18.22.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jul 2024 18:22:21 -0700 (PDT) Message-ID: Content-Type: multipart/alternative; boundary="Apple-Mail=_3B1CEFB1-C627-40F3-B037-5D2F033355E3" Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.8\)) Subject: Re: [PHP-DEV] [RFC] Deprecations for PHP 8.4 Date: Fri, 5 Jul 2024 21:22:20 -0400 In-Reply-To: <76838718-E108-4A08-A88F-4965FB81E52C@gmail.com> Cc: "Gina P. Banyard" , PHP internals To: Claude Pache References: <76838718-E108-4A08-A88F-4965FB81E52C@gmail.com> X-Mailer: Apple Mail (2.3696.120.41.1.8) From: mike@newclarity.net (Mike Schinkel) --Apple-Mail=_3B1CEFB1-C627-40F3-B037-5D2F033355E3 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Jul 5, 2024, at 1:11 PM, Claude Pache = wrote: >> Le 25 juin 2024 =C3=A0 16:36, Gina P. Banyard a = =C3=A9crit : >> https://wiki.php.net/rfc/deprecations_php_8_4 >=20 >=20 > * About strtok(): An exact replacement of `strtok()` that is = reasonably performant may be constructed with a sequence of strspn(...) = and strcspn(...) calls; here is an implementation using a generator in = order to keep the state: https://3v4l.org/926tC Well your modern_strtok() function is not an _exact_ replacement as it = requires using a generator and thus forces the restructure of the code = that calls strtok().=20 So not a drop-in =E2=80=94 search-and-replace =E2=80=94 replacement for = strtok(). But it is a reasonable replacement for those who are motivated = to do the restructure. =3D=3D=3D=3D=3D=3D=3D=3D Just out a curiosity for the performance of your modern_strtok() = function so I benchmarked it and found it takes =E2=80=94 on rough = average =E2=80=94 about ~2.5 times as long to run compared to when using = strtok(): https://3v4l.org/AMECf#v8.3.9 That makes yours the fastest alternative I have benchmarked, but = significantly still slower than strtok(). I was curious to see if I could improve its performance by avoiding the = generator, but that just made it slightly worse, e.g. taking =E2=80=94 = on rough average =E2=80=94 ~2.75 times as long to run as `strtok()`: https://3v4l.org/ZVS5Md#v8.3.9 #fwiw -Mike= --Apple-Mail=_3B1CEFB1-C627-40F3-B037-5D2F033355E3 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
On = Jul 5, 2024, at 1:11 PM, Claude Pache <claude.pache@gmail.com> wrote:
Le 25 juin 2024 =C3=A0 16:36, = Gina P. Banyard <internals@gpb.moe> a =C3=A9crit :

* About strtok(): An exact replacement = of `strtok()` that is reasonably performant may be constructed with a = sequence of strspn(...) and strcspn(...) calls; here is an = implementation using a generator in order to keep the state: https://3v4l.org/926tC
<= br class=3D"">
Well your modern_strtok() function is not = an _exact_ replacement as it requires using a generator and thus forces = the restructure of the code that calls strtok(). 

So not a drop-in =E2=80=94 search-and-replace =E2=80= =94 replacement for strtok(). But it is a reasonable replacement for = those who are motivated to do the restructure.

=3D=3D=3D=3D=3D=3D=3D=3D

Just out a curiosity for the performance of your = modern_strtok() function so I benchmarked it and found it takes =E2=80=94 = on rough average =E2=80=94 about ~2.5 times as long to run compared to = when using strtok():


That makes yours the fastest alternative I = have benchmarked, but significantly still slower than = strtok().

I was = curious to see if I could improve its performance by avoiding the = generator, but that just made it slightly worse, e.g. taking =E2=80=94 = on rough average =E2=80=94 ~2.75 times as long to run as = `strtok()`:


#fwiw

-Mike
= --Apple-Mail=_3B1CEFB1-C627-40F3-B037-5D2F033355E3--