[QuickLook] Use case-insensitive comparison of preview MIME types
[WebKit-https.git] / Source / WebCore / loader / ios / PreviewLoader.mm
index 569375d24eaaa2156a5406ff96690257c752dd4b..7c06ec58982f4f435fdc8224c71da28e71d7f7e3 100644 (file)
@@ -203,7 +203,14 @@ PreviewLoader::~PreviewLoader()
 
 bool PreviewLoader::shouldCreateForMIMEType(const String& mimeType)
 {
-    return [QLPreviewGetSupportedMIMETypesSet() containsObject:mimeType];
+    static std::once_flag onceFlag;
+    static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> supportedMIMETypes;
+    std::call_once(onceFlag, [] {
+        for (NSString *mimeType in QLPreviewGetSupportedMIMETypesSet())
+            supportedMIMETypes.get().add(mimeType);
+    });
+
+    return supportedMIMETypes.get().contains(mimeType);
 }
 
 std::unique_ptr<PreviewLoader> PreviewLoader::create(ResourceLoader& loader, const ResourceResponse& response)