diff options
author | James Tucker <jftucker@gmail.com> | 2022-11-09 20:49:30 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-10 05:49:30 +0100 |
commit | 78a6b871fe3dae308380ea88132ddadc86a1431e (patch) | |
tree | 355c20f14f76d034c9e2b9e90d2e9c86745d4b87 /app/controllers/api/v1 | |
parent | 0cd0786aef140ea41aa229cd52ac67867259a3f5 (diff) |
Improve performance by avoiding regex construction (#20215)
```ruby 10.times { p /#{FOO}/.object_id } 10.times { p FOO_RE.object_id } ```
Diffstat (limited to 'app/controllers/api/v1')
-rw-r--r-- | app/controllers/api/v1/tags_controller.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/app/controllers/api/v1/tags_controller.rb b/app/controllers/api/v1/tags_controller.rb index 9e5c53330..32f71bdce 100644 --- a/app/controllers/api/v1/tags_controller.rb +++ b/app/controllers/api/v1/tags_controller.rb @@ -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 |