Skip to content

Commit

Permalink
[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.
  • Loading branch information
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
Expand Up @@ -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

#
Expand Down

0 comments on commit 9de5fa0

Please sign in to comment.