Project

General

Profile

Bug #17030

Enumerable#grep{_v} should be optimized for Regexp

Added by marcandre (Marc-Andre Lafortune) 2 months ago. Updated 23 days ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:99156]

Description

Currently,

array.select { |e| e.match?(REGEXP) }

is about three times faster and six times more memory efficient than

array.grep(REGEXP)

This is because grep calls Regexp#===, which creates useless MatchData.

Also available in: Atom PDF