mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Cache regexp source on format validation to avoid allocating new objects
Example: >> r = /some-regexp/ => /some-regexp/ >> r.source.object_id == r.source.object_id => false
This commit is contained in:
parent
70161ae3b8
commit
b8c6c08452
1 changed files with 2 additions and 2 deletions
|
@ -33,8 +33,8 @@ module ActiveModel
|
||||||
end
|
end
|
||||||
|
|
||||||
def regexp_using_multiline_anchors?(regexp)
|
def regexp_using_multiline_anchors?(regexp)
|
||||||
regexp.source.start_with?("^") ||
|
source = regexp.source
|
||||||
(regexp.source.end_with?("$") && !regexp.source.end_with?("\\$"))
|
source.start_with?("^") || (source.end_with?("$") && !source.end_with?("\\$"))
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_options_validity(options, name)
|
def check_options_validity(options, name)
|
||||||
|
|
Loading…
Reference in a new issue