Improve performance by avoiding regex construction (#20215)
```ruby 10.times { p /#{FOO}/.object_id } 10.times { p FOO_RE.object_id } ```
This commit is contained in:
parent
0cd0786aef
commit
78a6b871fe
8 changed files with 21 additions and 12 deletions
|
@ -24,7 +24,7 @@ class Api::V1::TagsController < Api::BaseController
|
|||
private
|
||||
|
||||
def set_or_create_tag
|
||||
return not_found unless /\A(#{Tag::HASHTAG_NAME_RE})\z/.match?(params[:id])
|
||||
return not_found unless Tag::HASHTAG_NAME_RE.match?(params[:id])
|
||||
@tag = Tag.find_normalized(params[:id]) || Tag.new(name: Tag.normalize(params[:id]), display_name: params[:id])
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue