Bug 40602

Summary: Use an array for extensions in MimeClassInfo
Product: WebKit Reporter: Anders Carlsson <andersca>
Component: New BugsAssignee: Anders Carlsson <andersca>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, eric, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Other   
OS: OS X 10.5   
Attachments:
Description Flags
Patch darin: review+

Description Anders Carlsson 2010-06-14 18:14:36 PDT
Use an array for extensions in MimeClassInfo
Comment 1 Anders Carlsson 2010-06-14 18:16:47 PDT
Created attachment 58737 [details]
Patch
Comment 2 Anders Carlsson 2010-06-14 18:17:11 PDT
Please don't review this yet, I'd like to run it through the EWS bots.
Comment 3 Darin Adler 2010-06-14 18:20:39 PDT
Comment on attachment 58737 [details]
Patch

> +    const Vector<String> &extensions = mimeClassInfo().extensions;

The "&" here is in the wrong place.

> +    StringBuilder builder;
> +    for (size_t i = 0; i < extensions.size(); ++i) {
> +        if (i)
> +            builder.append(',');
> +        builder.append(extensions[i]);
> +    }
> +    return builder.toString();

Would Vector<UChar> do a better job? I never know which to use.

> +            NSArray *extensions = [plugin extensionsForMIMEType:MIME];
> +            NSUInteger count = [extensions count];
> +            for (NSUInteger i = 0; i < count; ++i) {
> +                NSString *extension = [extensions objectAtIndex:i];
> +                mime.extensions.append(extension);
> +            }

This is a lot like toStringVector in WebView.mm and WebEditorClient::getGuessesForWord in WebEditorClient.mm. I wish we had shared code to make NSArray of NSString into Vector<String> and vice versa.

r=me
Comment 4 Anders Carlsson 2010-06-14 18:27:06 PDT
(In reply to comment #3)
> (From update of attachment 58737 [details])
> > +    const Vector<String> &extensions = mimeClassInfo().extensions;
> 
> The "&" here is in the wrong place.
> 

Fixed.

> 
> Would Vector<UChar> do a better job? I never know which to use.

I don't think it matters; this code is not performance sensitive.

> This is a lot like toStringVector in WebView.mm and WebEditorClient::getGuessesForWord in WebEditorClient.mm. I wish we had shared code to make NSArray of NSString into Vector<String> and vice versa.

I agree. However, in this case I think that it would be better to convert WebKit over to using WebCore types for its plug-in database.

> 
> r=me

Thanks!
Comment 5 Anders Carlsson 2010-06-14 18:30:40 PDT
Committed r61168: <http://trac.webkit.org/changeset/61168>
Comment 6 WebKit Review Bot 2010-06-14 18:43:45 PDT
http://trac.webkit.org/changeset/61168 might have broken Chromium Linux Release