[webkit-reviews] review granted: [Bug 211794] [CG] Change the UTI of the "WebP" image to be "org.webmproject.webp" : [Attachment 399155] Patch

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue May 12 12:38:24 PDT 2020

Darin Adler <darin at apple.com> has granted Said Abou-Hallawa
<sabouhallawa at apple.com>'s request for review:
Bug 211794: [CG] Change the UTI of the "WebP" image to be

Attachment 399155: Patch


--- Comment #4 from Darin Adler <darin at apple.com> ---
Comment on attachment 399155
  --> https://bugs.webkit.org/attachment.cgi?id=399155

View in context: https://bugs.webkit.org/attachment.cgi?id=399155&action=review

> Source/WebCore/platform/graphics/cg/UTIRegistry.cpp:43
> +	   const char* defaultSupportedImageTypes[] = {

This is replacing a constant array with a non-constant array. Please add
constexpr or a const after the * so this array is constant. I think constexpr
is best.

> Source/WebCore/platform/graphics/cg/UTIRegistry.cpp:62
>	   RetainPtr<CFArrayRef> systemImageTypes =

Why not convert this into a temporary HashSet<String> instead of using it as a
CFArrayRef? Because we are doing to be doing the "contains" operation on it,
and that’s what a set does.

> Source/WebCore/platform/graphics/cg/UTIRegistry.cpp:66
> +	   for (const auto* imageType : defaultSupportedImageTypes) {

We can use "auto", "auto&", "auto*", or "const char*" for this loop variable,
but I don’t think "const auto*" is a great choice.

> Source/WebCore/platform/graphics/cg/UTIRegistry.cpp:67
> +	       RetainPtr<CFStringRef> string =
adoptCF(CFStringCreateWithCString(kCFAllocatorDefault, imageType,

There’s no good reason to use kCFStringEncodingUTF8 here. I suggest using
kCFStringEncodingASCII. But also, lets just make a String directly, and use a
HashSet<String> of the system image types instead of doing array searches.

More information about the webkit-reviews mailing list