Bug 95313 - Convert more static Strings to use ASCIILiteral
Summary: Convert more static Strings to use ASCIILiteral
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Adam Barth
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-29 01:52 PDT by Adam Barth
Modified: 2012-08-29 16:04 PDT (History)
11 users (show)

See Also:


Attachments
Patch (44.52 KB, patch)
2012-08-29 01:54 PDT, Adam Barth
no flags Details | Formatted Diff | Diff
Patch (44.99 KB, patch)
2012-08-29 09:30 PDT, Adam Barth
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Barth 2012-08-29 01:52:03 PDT
Convert more static Strings to use ASCIILiteral
Comment 1 Adam Barth 2012-08-29 01:54:08 PDT
Created attachment 161161 [details]
Patch
Comment 2 Eric Seidel (no email) 2012-08-29 02:20:55 PDT
Comment on attachment 161161 [details]
Patch

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

> Source/WebCore/Modules/mediasource/MediaSource.h:49
> +    static const String& openKeyword();
> +    static const String& closedKeyword();
> +    static const String& endedKeyword();

Thanks for saving the linker some work. :)

> Source/WebCore/css/CSSWrapShapes.cpp:127
> +            result.appendLiteral(", ");

I assume the compiler uniques these strings?  It or the linker must... for sanity's sake.

> Source/WebCore/css/StyleSheetContents.cpp:294
> +        if (baseURL().string().endsWith("/KHTMLFixes.css") && !sheetText.isNull() && mediaWikiKHTMLFixesStyleSheet.startsWith(sheetText)

The web it an amazing place.

> Source/WebCore/editing/markup.cpp:203
>  const String StyledMarkupAccumulator::styleNodeCloseTag(bool isBlock)

This could be const String&

> Source/WebCore/editing/markup.cpp:555
>          return "";

Oh noes.

> Source/WebCore/platform/KURLWTFURL.cpp:116
> +    if (isNull())
> +        return String();

Returning a reference to a temporary seems like a bad idea?  How does the compiler allow this?

> Source/WebCore/platform/MIMETypeRegistry.cpp:641
> +    mimeTypeMap->add(ASCIILiteral("image/x-ms-bmp"), ASCIILiteral("image/bmp")));

I would have created an addLiterals(map, key, value) helper if I had writen this.

> Source/WebCore/svg/SVGAnimatedBoolean.cpp:37
> +    animtedType->boolean() = (string == "true"); // wat?

Yes.  Wat?
Comment 3 Adam Barth 2012-08-29 08:26:44 PDT
(In reply to comment #2)
> (From update of attachment 161161 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=161161&action=review
> 
> > Source/WebCore/platform/KURLWTFURL.cpp:116
> > +    if (isNull())
> > +        return String();
> 
> Returning a reference to a temporary seems like a bad idea?  How does the compiler allow this?

Hum...  You're right.  We should use nullAtom.
Comment 4 Adam Barth 2012-08-29 08:27:58 PDT
Comment on attachment 161161 [details]
Patch

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

>> Source/WebCore/css/CSSWrapShapes.cpp:127
>> +            result.appendLiteral(", ");
> 
> I assume the compiler uniques these strings?  It or the linker must... for sanity's sake.

Yes.
Comment 5 Adam Barth 2012-08-29 09:28:50 PDT
(In reply to comment #2)
> (From update of attachment 161161 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=161161&action=review
> 
> > Source/WebCore/platform/MIMETypeRegistry.cpp:641
> > +    mimeTypeMap->add(ASCIILiteral("image/x-ms-bmp"), ASCIILiteral("image/bmp")));
> 
> I would have created an addLiterals(map, key, value) helper if I had writen this.

Yeah, the issue is that mimeTypeMap is a WTF template object and that sort of thing only makes sense for String.  We could make a subclass, but this seemed easier.
Comment 6 Adam Barth 2012-08-29 09:30:24 PDT
Created attachment 161246 [details]
Patch
Comment 7 Eric Seidel (no email) 2012-08-29 10:07:15 PDT
(In reply to comment #5)
> (In reply to comment #2)
> > (From update of attachment 161161 [details] [details])
> > View in context: https://bugs.webkit.org/attachment.cgi?id=161161&action=review
> > 
> > > Source/WebCore/platform/MIMETypeRegistry.cpp:641
> > > +    mimeTypeMap->add(ASCIILiteral("image/x-ms-bmp"), ASCIILiteral("image/bmp")));
> > 
> > I would have created an addLiterals(map, key, value) helper if I had writen this.
> 
> Yeah, the issue is that mimeTypeMap is a WTF template object and that sort of thing only makes sense for String.  We could make a subclass, but this seemed easier.

I meant a static inline helper function. :)
Comment 8 Eric Seidel (no email) 2012-08-29 10:08:08 PDT
Comment on attachment 161246 [details]
Patch

LGTM.
Comment 9 Adam Barth 2012-08-29 10:10:54 PDT
(In reply to comment #7)
> (In reply to comment #5)
> > (In reply to comment #2)
> > > (From update of attachment 161161 [details] [details] [details])
> > > View in context: https://bugs.webkit.org/attachment.cgi?id=161161&action=review
> > > 
> > > > Source/WebCore/platform/MIMETypeRegistry.cpp:641
> > > > +    mimeTypeMap->add(ASCIILiteral("image/x-ms-bmp"), ASCIILiteral("image/bmp")));
> > > 
> > > I would have created an addLiterals(map, key, value) helper if I had writen this.
> > 
> > Yeah, the issue is that mimeTypeMap is a WTF template object and that sort of thing only makes sense for String.  We could make a subclass, but this seemed easier.
> 
> I meant a static inline helper function. :)

Ah...  Ok.
Comment 10 Benjamin Poulain 2012-08-29 12:25:23 PDT
> >> Source/WebCore/css/CSSWrapShapes.cpp:127
> >> +            result.appendLiteral(", ");
> > 
> > I assume the compiler uniques these strings?  It or the linker must... for sanity's sake.
> 
> Yes.

I can confirm this, I verified that a while ago.
Comment 11 WebKit Review Bot 2012-08-29 16:04:03 PDT
Comment on attachment 161246 [details]
Patch

Clearing flags on attachment: 161246

Committed r127062: <http://trac.webkit.org/changeset/127062>
Comment 12 WebKit Review Bot 2012-08-29 16:04:08 PDT
All reviewed patches have been landed.  Closing bug.