Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Truffle] Do not cache Regexp#named_captures.
Browse files Browse the repository at this point in the history
* It is not a fast-path operation, neither Regexp#names nor MatchData#names.
* Caching still involves Hash#dup.
* See #4436.
eregon committed Jan 12, 2017
1 parent 6b656fc commit 9de5fa0
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions truffle/src/main/ruby/core/regexp.rb
Original file line number Diff line number Diff line change
@@ -309,15 +309,7 @@ def option_to_string(option)
# #=> {}
#
def named_captures
if @named_captures
@named_captures.dup
else
named_captures = Hash[Truffle.invoke_primitive(:regexp_names, self)]
unless frozen?
@named_captures = named_captures.dup.freeze
end
named_captures
end
Hash[Truffle.invoke_primitive(:regexp_names, self)]
end

#

0 comments on commit 9de5fa0

Please sign in to comment.