diff options
author | Sean McGivern <sean@gitlab.com> | 2019-05-11 07:06:44 -0500 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-05-14 11:01:48 -0500 |
commit | 79dd92c8189600f24a29fe2da8d391cdb021f8fd (patch) | |
tree | fff4f45718495005bcacc82156bf7fc05943a568 /app/models | |
parent | 513fa60310e5b5d8dbdf81daf0c6ae7e506b4d8b (diff) | |
download | gitlab-ce-79dd92c8189600f24a29fe2da8d391cdb021f8fd.tar.gz |
Optimise upload path calls
String#underscore isn't particularly slow, but it's possible for us to
call it many times in a users autocomplete request, with mostly-static
values ('User', 'Group', etc.). We can memoise this and save a
surprising amount of time (around 10% of the total request time in some
cases).
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/application_record.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/app/models/application_record.rb b/app/models/application_record.rb index d1d01368972..0979d03f6e6 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -41,4 +41,8 @@ class ApplicationRecord < ActiveRecord::Base find_or_create_by(*args) end end + + def self.underscore + Gitlab::SafeRequestStore.fetch("model:#{self}:underscore") { self.to_s.underscore } + end end |