Bug 40602 - Use an array for extensions in MimeClassInfo
Summary: Use an array for extensions in MimeClassInfo
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Other OS X 10.5
: P2 Normal
Assignee: Anders Carlsson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-14 18:14 PDT by Anders Carlsson
Modified: 2010-06-14 18:43 PDT (History)
3 users (show)

See Also:


Attachments
Patch (8.38 KB, patch)
2010-06-14 18:16 PDT, Anders Carlsson
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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