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=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 5CEE71F66E for ; Tue, 25 Aug 2020 17:23:54 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 95253120900; Wed, 26 Aug 2020 02:23:21 +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 3E9201208FE for ; Wed, 26 Aug 2020 02:23:19 +0900 (JST) Received: by filterdrecv-p3iad2-56dbc8bd54-lvpgd with SMTP id filterdrecv-p3iad2-56dbc8bd54-lvpgd-17-5F454920-AF 2020-08-25 17:23:44.54007871 +0000 UTC m=+91566.548821458 Received: from herokuapp.com (unknown) by ismtpd0020p1iad2.sendgrid.net (SG) with ESMTP id _y5tC-aCR-mqhzlIl1BvZQ for ; Tue, 25 Aug 2020 17:23:44.400 +0000 (UTC) Date: Tue, 25 Aug 2020 17:23:44 +0000 (UTC) From: fatkodima123@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 75519 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?RvZ0H4gD69HjmyxuoEldmMenU4znNUKl7mOsZIogdq4PGTRJy5uSJzozLnTiO9?= =?us-ascii?Q?6TI3vKdY3Aw8FuvElR0tdzqnk5Sz4GuJ6VCs0yu?= =?us-ascii?Q?S+ZRvlDWFV857E69qmfBH+62UDB5qgdXFYsXGiW?= =?us-ascii?Q?DLv66Cm6RyfYWJc5F+HgiJtGBXYi9s3UplIW8DA?= =?us-ascii?Q?HZ2V9WLCiUkxvC4EKkKYr1GIX6R1vEx4B9tIrl1?= =?us-ascii?Q?=2FGUJ74HMEOaKzTh48=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 99687 Subject: [ruby-core:99687] [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). I like @scivola20 's idea and would like to try to implement it. Before starting, @nobu, wdyt, is this something that will be merged? ---------------------------------------- Bug #17030: Enumerable#grep{_v} should be optimized for Regexp https://bugs.ruby-lang.org/issues/17030#change-87177 * 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/