Extract UTI mapping and allow for additions
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 14 Apr 2019 20:14:19 +0000 (20:14 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 14 Apr 2019 20:14:19 +0000 (20:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196822
<rdar://problem/49822339>

Reviewed by Darin Adler

Post landing feedback on minimizing String constructors.

* platform/network/mac/UTIUtilities.mm:
(WebCore::MIMETypeFromUTITree):
(WebCore::UTIFromMIMETypeCachePolicy::createValueForKey):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244247 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/network/mac/UTIUtilities.mm

index 15ac8ea..c2d6d5a 100644 (file)
@@ -1,3 +1,17 @@
+2019-04-14  Dean Jackson  <dino@apple.com>
+
+        Extract UTI mapping and allow for additions
+        https://bugs.webkit.org/show_bug.cgi?id=196822
+        <rdar://problem/49822339>
+
+        Reviewed by Darin Adler
+
+        Post landing feedback on minimizing String constructors.
+
+        * platform/network/mac/UTIUtilities.mm:
+        (WebCore::MIMETypeFromUTITree):
+        (WebCore::UTIFromMIMETypeCachePolicy::createValueForKey):
+
 2019-04-14  Don Olmstead  <don.olmstead@sony.com>
 
         [CMake] JavaScriptCore derived sources should only be referenced inside JavaScriptCore
index 59f7391..65b28d0 100644 (file)
@@ -58,10 +58,10 @@ String MIMETypeFromUTITree(const String& uti)
     // If not, walk the ancestory of this UTI via its "ConformsTo" tags and return the first MIME type we find.
     RetainPtr<CFDictionaryRef> decl = adoptCF(UTTypeCopyDeclaration(utiCF.get()));
     if (!decl)
-        return String();
+        return emptyString();
     CFTypeRef value = CFDictionaryGetValue(decl.get(), kUTTypeConformsToKey);
     if (!value)
-        return String();
+        return emptyString();
     CFTypeID typeID = CFGetTypeID(value);
 
     if (typeID == CFStringGetTypeID())
@@ -81,7 +81,7 @@ String MIMETypeFromUTITree(const String& uti)
         }
     }
 
-    return String();
+    return emptyString();
 }
 
 static String UTIFromUnknownMIMEType(const String& mimeType)
@@ -118,7 +118,7 @@ public:
     {
         auto type = adoptCF(UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, key.createCFString().get(), 0));
         if (type)
-            return String(type.get());
+            return type.get();
         return UTIFromUnknownMIMEType(key);
     }
 };