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-Status: No, score=-2.6 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=no autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 6A66F1F66E for ; Wed, 26 Aug 2020 08:31:56 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id BE78B120A15; Wed, 26 Aug 2020 17:31:20 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id B0496120A0F for ; Wed, 26 Aug 2020 17:31:18 +0900 (JST) Received: by filterdrecv-p3iad2-cbd967498-hbcth with SMTP id filterdrecv-p3iad2-cbd967498-hbcth-20-5F461DF4-1C 2020-08-26 08:31:48.193566897 +0000 UTC m=+46892.129638229 Received: from herokuapp.com (unknown) by ismtpd0001p1iad2.sendgrid.net (SG) with ESMTP id yVWj1WcoRwuM6d1si_5F2A for ; Wed, 26 Aug 2020 08:31:48.062 +0000 (UTC) Date: Wed, 26 Aug 2020 08:31:48 +0000 (UTC) From: fatkodima123@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 75534 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 17030 X-Redmine-Issue-Author: marcandre X-Redmine-Sender: fatkodima 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-SG-EID: =?us-ascii?Q?RvZ0H4gD69HjmyxuoEldmMenU4znNUKl7mOsZIogdq4JcCLt7NDap3EIs33kuq?= =?us-ascii?Q?3KSqtwEUBgp3aEK2TWzq0nKJmkwThcfAOx2P4KC?= =?us-ascii?Q?La+ny6h2=2FEPs0VZ0fis8GceWr8iDmSgQuLCJtSH?= =?us-ascii?Q?YPLfDxRIhnEpLKyNgPXig1SsoQi7W42udat5jV3?= =?us-ascii?Q?fnul2l6mEjhrNcw2ll2oC9bYdMYRZmX+dJajoX2?= =?us-ascii?Q?IYb2oRihm+WF7URc4=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 99702 Subject: [ruby-core:99702] [Ruby master Bug#17030] Enumerable#grep{_v} should be optimized for Regexp X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #17030 has been updated by fatkodima (Dima Fatko). sawa (Tsuyoshi Sawada) wrote in #note-10: > I feel scivola20 (sciv ola)'s idea promising, but have a concern that it is going to introduce the same kind of mess as when `"string"f` notation was introduced (same "f" used due to frozen and fast, but this is just coincidental). People are going to need to write `/regex/f` all over the place. > > Just by analogy from the situation with strings, what about introducing the following pragma, which will make all regex literals on that page fast regex literals (i.e., `===` becomes `match?`)? > > ```ruby > # boolean_regex_literal: true > ``` > > And perhaps in the long run, Matz might want to make all regexes work like that, or simply change the definition of `Regexp#===`. Yes, seems like this will solve the problem of typing `regex/f` all over. Does it also mean that we then should have something like in frozen string world (`String#@+`) to manually change to the old behavior where we need it, like ```ruby # boolean_regex_literal: true case var when /foo/ # does not set $~, etc when +/bar/ # sets $~, etc end ``` ? ---------------------------------------- Bug #17030: Enumerable#grep{_v} should be optimized for Regexp https://bugs.ruby-lang.org/issues/17030#change-87192 * Author: marcandre (Marc-Andre Lafortune) * Status: Open * Priority: Normal * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- Currently: ```ruby array.select { |e| e.match?(REGEXP) } # about 3x faster and 6x more memory efficient than array.grep(REGEXP) ``` This is because `grep` calls `Regexp#===` which creates useless `MatchData` -- https://bugs.ruby-lang.org/