Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
paperclip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
paperclip
Commits
993a47b2
Commit
993a47b2
authored
9 years ago
by
Dave Gynn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
speed up interpolation by consolidating interpolator caches
parent
3def1e1e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
8 deletions
+4
-8
lib/paperclip/interpolations.rb
+4
-8
No files found.
lib/paperclip/interpolations.rb
View file @
993a47b2
...
...
@@ -21,7 +21,7 @@ module Paperclip
# Returns a sorted list of all interpolations.
def
self
.
all
self
.
instance_methods
(
false
).
sort
self
.
instance_methods
(
false
).
sort
!
end
# Perform the actual interpolation. Takes the pattern to interpolate
...
...
@@ -31,18 +31,14 @@ module Paperclip
def
self
.
interpolate
pattern
,
*
args
pattern
=
args
.
first
.
instance
.
send
(
pattern
)
if
pattern
.
kind_of?
Symbol
result
=
pattern
.
dup
interpolators_cache
.
each
do
|
tag
|
result
.
gsub!
(
t
ag_pattern_cache
[
tag
])
{
send
(
tag
,
*
args
)
}
interpolators_cache
.
each
do
|
method
,
token
|
result
.
gsub!
(
t
oken
)
{
send
(
method
,
*
args
)
}
if
result
.
include?
(
token
)
end
result
end
def
self
.
tag_pattern_cache
@tag_pattern_cache
||=
Hash
.
new
{
|
hash
,
key
|
hash
[
key
]
=
":
#{
key
}
"
}
end
def
self
.
interpolators_cache
@interpolators_cache
||=
all
.
reverse!
@interpolators_cache
||=
all
.
reverse!
.
map!
{
|
method
|
[
method
,
":
#{
method
}
"
]
}
end
def
self
.
plural_cache
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment