Skip to content

Commit 2b25f39

Browse files
committed
more memoization
1 parent 1f88f26 commit 2b25f39

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

app/lib/supported_mime_types.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def loadable
6262
def can_load?(type)
6363
loadable.include? type
6464
end
65+
memoize :can_load?
6566

6667
def exportable
6768
Mime::EXTENSION_LOOKUP.slice(
@@ -73,6 +74,7 @@ def exportable
7374
def can_export?(type)
7475
exportable.include? type
7576
end
77+
memoize :can_export?
7678

7779
def renderable
7880
readers = `f3d --list-readers`.lines
@@ -84,6 +86,7 @@ def renderable
8486
def can_render?(type)
8587
renderable.include? type&.to_sym
8688
end
89+
memoize :can_render?
8790

8891
def indexable_types
8992
image_types + model_types + video_types + document_types + archive_types
@@ -104,10 +107,12 @@ def is_image_mime_type?(type)
104107
]
105108
type.to_s.start_with?("image/") && exclusions.exclude?(type.to_s)
106109
end
110+
memoize :is_image_mime_type?
107111

108112
def is_video_mime_type?(type)
109113
type.to_s.start_with?("video/")
110114
end
115+
memoize :is_video_mime_type?
111116

112117
def is_document_mime_type?(type)
113118
[
@@ -129,6 +134,7 @@ def is_document_mime_type?(type)
129134
"application/x-kicad-worksheet"
130135
].include?(type.to_s)
131136
end
137+
memoize :is_document_mime_type?
132138

133139
def is_model_mime_type?(type)
134140
extras = [
@@ -143,6 +149,7 @@ def is_model_mime_type?(type)
143149
]
144150
type.to_s.start_with?("model/") || extras.include?(type.to_s)
145151
end
152+
memoize :is_model_mime_type?
146153

147154
def is_archive_mime_type?(type)
148155
[
@@ -153,5 +160,6 @@ def is_archive_mime_type?(type)
153160
"application/x-bzip2"
154161
].include?(type.to_s)
155162
end
163+
memoize :is_archive_mime_type?
156164
end
157165
end

0 commit comments

Comments
 (0)