From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-3.6 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, SPF_HELO_PASS,SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from nue.mailmanlists.eu (nue.mailmanlists.eu [IPv6:2a01:4f8:1c0c:6b10::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id BA54B1F852 for ; Sun, 25 Dec 2022 01:13:40 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; secure) header.d=ml.ruby-lang.org header.i=@ml.ruby-lang.org header.b="CS5qovrX"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.b="fGcElaji"; dkim-atps=neutral Received: from nue.mailmanlists.eu (localhost [127.0.0.1]) by nue.mailmanlists.eu (Postfix) with ESMTP id EDA3F7E81A; Sun, 25 Dec 2022 01:13:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ml.ruby-lang.org; s=mail; t=1671930804; bh=t5yxvOjpCrF3ojx8kArleA6R1Lny8PrjyQo4QeL/7sk=; h=Date:References:To:Reply-To:Subject:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From:Cc:From; b=CS5qovrX/PvrZGcCrX9f7AUGIPIkMxvFbfkvNKICyEUG6WAv5cR8Zdrd5pr8KW8E/ gFcmdAZVp7cibmo5OfG5EJqkJN68l27g4gHAUHosJ3T23tum7UD2lA+vD6rDvwNGpV YsEUBReSM3e5k2RSY+yoIyI6ZuMmkYzR9BdepDDM= Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by nue.mailmanlists.eu (Postfix) with ESMTPS id 131CD7E6B4 for ; Sun, 25 Dec 2022 01:13:17 +0000 (UTC) Authentication-Results: nue.mailmanlists.eu; dkim=pass (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=fGcElaji; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ruby-lang.org; h=from:references:subject:mime-version:content-type: content-transfer-encoding:list-id:to:cc:content-type:from:subject:to; s=s1; bh=5KHOM/CVYtRi8rMW7Uh05Qc8dRJZpjv+0H4XPZ1IiVo=; b=fGcElajiBDo+xeIaoyL01Tngv2y89BHIRAfEaV+2e+0bbStjxz6Ku/0gzU0Y4a65TwMh bDMDl2aEodx+Y9rV/ymYMQWlrzFNjMgXOgRXIuxPsUpaHqoa0TLXiuESMK0gFAX72AkS+B MnL+H0wK3LvpVxHFhbZ9+Rh95Ocn56FAzFn0jTDrHpCCszu40rBkTn5ISU0TrG84ogB5xj jerZgAD0joLsSG/CFukKsFZOKRneAPwZaW8ofV7uRtDfm757HmhT5Jj4ttblDy2+jWlbS8 1aKvLnxzFh2d/B9SrJWMdizHnFST7v7coaOXPPYLIqutpqgOpDqdnblZcgaTGAiA== Received: by filterdrecv-6c4ccfbdd8-wnrfr with SMTP id filterdrecv-6c4ccfbdd8-wnrfr-1-63A79422-D 2022-12-25 00:06:58.245276989 +0000 UTC m=+3200486.697391123 Received: from herokuapp.com (unknown) by geopod-ismtpd-3-1 (SG) with ESMTP id XlRRcUVgQhmFoukMHsgv5w for ; Sun, 25 Dec 2022 00:06:58.053 +0000 (UTC) Date: Sun, 25 Dec 2022 00:06:58 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 19194 X-Redmine-Issue-Author: make_now_just X-Redmine-Issue-Assignee: make_now_just X-Redmine-Sender: jnchito X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-Redmine-MailingListIntegration-Message-Ids: 87821 X-SG-EID: =?us-ascii?Q?7YRTdf4jqXBG6DCUVG=2Fakb0M6kKP5c0jYBt4dlQNzcrLWo4X=2FedktPicAg1wM3?= =?us-ascii?Q?GpV3HQGuCfJnJxJlr8I2utXb2ww6IVSo1hs6Wb1?= =?us-ascii?Q?KBxNdAkfXpgplEK9SB3eKwF5oM4ob77+4Lr1uXB?= =?us-ascii?Q?VS4jxbmAQr79wN0i12rPZtcLwBZJ1kdzrdqQ2AK?= =?us-ascii?Q?+bKxWcMudLeI+ofRObmVdkjJPkGdNz+fhcS4cXM?= =?us-ascii?Q?yLe7eYTAFab4BTJZ8jdlotDMnSbUwRA3CrAhMTh?= =?us-ascii?Q?9w05LJ317FSyQpRolJvKQ=3D=3D?= To: ruby-dev@ml.ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== Message-ID-Hash: 5MRSSHU7LFP5THAI3WG4DON3FIXTLYN4 X-Message-ID-Hash: 5MRSSHU7LFP5THAI3WG4DON3FIXTLYN4 X-MailFrom: bounces+313651-12dc-ruby-dev=ml.ruby-lang.org@em5188.ruby-lang.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list Reply-To: "Ruby developers (Japanese)" Subject: =?utf-8?q?=5Bruby-dev=3A52031=5D_?= [Ruby master Feature#19194] Add Regexp.linear_time? List-Id: "Ruby developers (Japanese)" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: "jnchito (Junichi Ito) via ruby-dev" Cc: "jnchito (Junichi Ito)" Issue #19194 has been updated by jnchito (Junichi Ito). I feel it would be more natural if it was defined as instance method: ``` ruby /a/.linear_time? Regexp.new('a').linear_time? ``` Is there any reason for class method? ---------------------------------------- Feature #19194: Add Regexp.linear_time? https://bugs.ruby-lang.org/issues/19194#change-100792 * Author: make_now_just (Hiroya Fujinami) * Status: Closed * Priority: Normal * Assignee: make_now_just (Hiroya Fujinami) * Target version: 3.2 ---------------------------------------- I suggest adding a new method named `Regexp.linear_time?` to check if matching against a given regexp can be completed in linear time by the optimization introduced in #19104 (GitHub PR [#6486](https://github.com/ruby/ruby/pull/6486)). This method was discussed in #19104. I'm not sure the name is best. # Example ``` Regexp.linear_time?(/a/) # => true Regexp.linear_time?(/(a|a)*\1/) # => false, because this uses a back-reference. # This can accept a regexp source string and flags like `Regexp.new`. Regexp.linear_time?('a') # => true Regexp.linear_time?('a', Regexp::IGNORECASE) # => true ``` For example, this method is useful for implementing a Rubocop rule to check a regexp is ReDoS safe. # Implementation Implementation is done at GitHub PR [#6901](https://github.com/ruby/ruby/pull/6901). See the details there. -- https://bugs.ruby-lang.org/