Project

General

Profile

Actions

Bug #17030

closed

Enumerable#grep{_v} should be optimized for Regexp

Added by marcandre (Marc-Andre Lafortune) almost 4 years ago. Updated over 3 years ago.

Status:
Closed
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.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0