Changeset 154023 in webkit


Ignore:
Timestamp:
Aug 13, 2013 2:42:16 PM (11 years ago)
Author:
andersca@apple.com
Message:

Stop using DEFINE_STATIC_LOCAL with RefPtr
https://bugs.webkit.org/show_bug.cgi?id=119769

Reviewed by Andreas Kling.

No need to waste heap memory allocating RefPtr, just store the raw pointers directly.

  • dom/ContextFeatures.cpp:

(WebCore::ContextFeatures::defaultSwitch):

  • dom/DocumentMarker.cpp:

(WebCore::DocumentMarkerTextMatch::instanceFor):

  • editing/EditingStyle.cpp:

(WebCore::StyleChange::extractTextStyles):

  • html/FTPDirectoryDocument.cpp:

(WebCore::FTPDirectoryDocumentParser::loadDocumentTemplate):

  • html/HTMLPlugInImageElement.cpp:

(WebCore::HTMLPlugInImageElement::didAddUserAgentShadowRoot):

  • html/track/TextTrack.cpp:

(WebCore::TextTrack::captionMenuOffItem):
(WebCore::TextTrack::captionMenuAutomaticItem):

  • loader/icon/IconDatabase.cpp:

(WebCore::loadDefaultIconRecord):

  • platform/graphics/Image.cpp:

(WebCore::Image::nullImage):

  • platform/graphics/PlatformTextTrack.h:

(WebCore::PlatformTextTrack::captionMenuOffItem):
(WebCore::PlatformTextTrack::captionMenuAutomaticItem):

  • rendering/style/RenderStyle.cpp:

(WebCore::RenderStyle::initialShapeInside):

  • testing/MockCDM.cpp:

(WebCore::initDataPrefix):
(WebCore::keyPrefix):
(WebCore::keyRequest):

Location:
trunk/Source/WebCore
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r154021 r154023  
     12013-08-13  Anders Carlsson  <andersca@apple.com>
     2
     3        Stop using DEFINE_STATIC_LOCAL with RefPtr
     4        https://bugs.webkit.org/show_bug.cgi?id=119769
     5
     6        Reviewed by Andreas Kling.
     7
     8        No need to waste heap memory allocating RefPtr, just store the raw pointers directly.
     9
     10        * dom/ContextFeatures.cpp:
     11        (WebCore::ContextFeatures::defaultSwitch):
     12        * dom/DocumentMarker.cpp:
     13        (WebCore::DocumentMarkerTextMatch::instanceFor):
     14        * editing/EditingStyle.cpp:
     15        (WebCore::StyleChange::extractTextStyles):
     16        * html/FTPDirectoryDocument.cpp:
     17        (WebCore::FTPDirectoryDocumentParser::loadDocumentTemplate):
     18        * html/HTMLPlugInImageElement.cpp:
     19        (WebCore::HTMLPlugInImageElement::didAddUserAgentShadowRoot):
     20        * html/track/TextTrack.cpp:
     21        (WebCore::TextTrack::captionMenuOffItem):
     22        (WebCore::TextTrack::captionMenuAutomaticItem):
     23        * loader/icon/IconDatabase.cpp:
     24        (WebCore::loadDefaultIconRecord):
     25        * platform/graphics/Image.cpp:
     26        (WebCore::Image::nullImage):
     27        * platform/graphics/PlatformTextTrack.h:
     28        (WebCore::PlatformTextTrack::captionMenuOffItem):
     29        (WebCore::PlatformTextTrack::captionMenuAutomaticItem):
     30        * rendering/style/RenderStyle.cpp:
     31        (WebCore::RenderStyle::initialShapeInside):
     32        * testing/MockCDM.cpp:
     33        (WebCore::initDataPrefix):
     34        (WebCore::keyPrefix):
     35        (WebCore::keyRequest):
     36
    1372013-08-13  Anders Carlsson  <andersca@apple.com>
    238
  • trunk/Source/WebCore/dom/ContextFeatures.cpp

    r150652 r154023  
    4747ContextFeatures* ContextFeatures::defaultSwitch()
    4848{
    49     DEFINE_STATIC_LOCAL(RefPtr<ContextFeatures>, instance, (ContextFeatures::create(ContextFeaturesClient::empty())));
    50     return instance.get();
     49    static ContextFeatures* instance = ContextFeatures::create(ContextFeaturesClient::empty()).leakRef();
     50    return instance;
    5151}
    5252
  • trunk/Source/WebCore/dom/DocumentMarker.cpp

    r114220 r154023  
    8585PassRefPtr<DocumentMarkerTextMatch> DocumentMarkerTextMatch::instanceFor(bool match)
    8686{
    87     DEFINE_STATIC_LOCAL(RefPtr<DocumentMarkerTextMatch>, trueInstance, (adoptRef(new DocumentMarkerTextMatch(true))));
    88     DEFINE_STATIC_LOCAL(RefPtr<DocumentMarkerTextMatch>, falseInstance, (adoptRef(new DocumentMarkerTextMatch(false))));
     87    static DocumentMarkerTextMatch* trueInstance = adoptRef(new DocumentMarkerTextMatch(true)).leakRef();
     88    static DocumentMarkerTextMatch* falseInstance = adoptRef(new DocumentMarkerTextMatch(false)).leakRef();
    8989    return match ? trueInstance : falseInstance;
    9090}
  • trunk/Source/WebCore/editing/EditingStyle.cpp

    r153926 r154023  
    3535#include "CSSValueKeywords.h"
    3636#include "CSSValueList.h"
     37#include "CSSValuePool.h"
    3738#include "Editor.h"
    3839#include "Frame.h"
     
    10631064static void mergeTextDecorationValues(CSSValueList* mergedValue, const CSSValueList* valueToMerge)
    10641065{
    1065     DEFINE_STATIC_LOCAL(const RefPtr<CSSPrimitiveValue>, underline, (CSSPrimitiveValue::createIdentifier(CSSValueUnderline)));
    1066     DEFINE_STATIC_LOCAL(const RefPtr<CSSPrimitiveValue>, lineThrough, (CSSPrimitiveValue::createIdentifier(CSSValueLineThrough)));
     1066    RefPtr<CSSPrimitiveValue> underline = cssValuePool().createIdentifierValue(CSSValueUnderline);
     1067    RefPtr<CSSPrimitiveValue> lineThrough = cssValuePool().createIdentifierValue(CSSValueLineThrough);
    10671068
    10681069    if (valueToMerge->hasValue(underline.get()) && !mergedValue->hasValue(underline.get()))
     
    14281429    RefPtr<CSSValue> textDecoration = style->getPropertyCSSValue(CSSPropertyTextDecoration);
    14291430    if (textDecoration && textDecoration->isValueList()) {
    1430         DEFINE_STATIC_LOCAL(RefPtr<CSSPrimitiveValue>, underline, (CSSPrimitiveValue::createIdentifier(CSSValueUnderline)));
    1431         DEFINE_STATIC_LOCAL(RefPtr<CSSPrimitiveValue>, lineThrough, (CSSPrimitiveValue::createIdentifier(CSSValueLineThrough)));
     1431        RefPtr<CSSPrimitiveValue> underline = cssValuePool().createIdentifierValue(CSSValueUnderline);
     1432        RefPtr<CSSPrimitiveValue> lineThrough = cssValuePool().createIdentifierValue(CSSValueLineThrough);
    14321433
    14331434        RefPtr<CSSValueList> newTextDecoration = static_cast<CSSValueList*>(textDecoration.get())->copy();
  • trunk/Source/WebCore/html/FTPDirectoryDocument.cpp

    r152440 r154023  
    290290bool FTPDirectoryDocumentParser::loadDocumentTemplate()
    291291{
    292     DEFINE_STATIC_LOCAL(RefPtr<SharedBuffer>, templateDocumentData, (createTemplateDocumentData(document()->settings())));
     292    static SharedBuffer* templateDocumentData = createTemplateDocumentData(document()->settings()).leakRef();
    293293    // FIXME: Instead of storing the data, we'd rather actually parse the template data into the template Document once,
    294294    // store that document, then "copy" it whenever we get an FTP directory listing.  There are complexities with this
  • trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp

    r153927 r154023  
    373373    String mimeType = loadedMimeType();
    374374
    375     DEFINE_STATIC_LOCAL(RefPtr<DOMWrapperWorld>, isolatedWorld, (DOMWrapperWorld::create(JSDOMWindow::commonVM())));
    376     document()->ensurePlugInsInjectedScript(isolatedWorld.get());
     375    static DOMWrapperWorld* isolatedWorld = DOMWrapperWorld::create(JSDOMWindow::commonVM()).leakRef();
     376    document()->ensurePlugInsInjectedScript(isolatedWorld);
    377377
    378378    ScriptController* scriptController = page->mainFrame()->script();
    379     JSDOMGlobalObject* globalObject = JSC::jsCast<JSDOMGlobalObject*>(scriptController->globalObject(isolatedWorld.get()));
     379    JSDOMGlobalObject* globalObject = JSC::jsCast<JSDOMGlobalObject*>(scriptController->globalObject(isolatedWorld));
    380380    JSC::ExecState* exec = globalObject->globalExec();
    381381
  • trunk/Source/WebCore/html/track/TextTrack.cpp

    r153926 r154023  
    104104TextTrack* TextTrack::captionMenuOffItem()
    105105{
    106     DEFINE_STATIC_LOCAL(RefPtr<TextTrack>, off, (TextTrack::create(0, 0, "off menu item", "", "")));
    107     return off.get();
     106    static TextTrack* off = TextTrack::create(0, 0, "off menu item", "", "").leakRef();
     107    return off;
    108108}
    109109
    110110TextTrack* TextTrack::captionMenuAutomaticItem()
    111111{
    112     DEFINE_STATIC_LOCAL(RefPtr<TextTrack>, automatic, (TextTrack::create(0, 0, "automatic menu item", "", "")));
    113     return automatic.get();
     112    static TextTrack* automatic = TextTrack::create(0, 0, "automatic menu item", "", "").leakRef();
     113    return automatic;
    114114}
    115115
  • trunk/Source/WebCore/loader/icon/IconDatabase.cpp

    r149965 r154023  
    390390        0xFC, 0x80, 0x00, 0x00, 0x27, 0x10, 0x00, 0x0A, 0xFC, 0x80, 0x00, 0x00, 0x27, 0x10 };
    391391       
    392     DEFINE_STATIC_LOCAL(RefPtr<SharedBuffer>, defaultIconBuffer, (SharedBuffer::create(defaultIconData, sizeof(defaultIconData))));
     392    static SharedBuffer* defaultIconBuffer = SharedBuffer::create(defaultIconData, sizeof(defaultIconData)).leakRef();
    393393    defaultIconRecord->setImageData(defaultIconBuffer);
    394394}
  • trunk/Source/WebCore/platform/graphics/Image.cpp

    r149056 r154023  
    5858{
    5959    ASSERT(isMainThread());
    60     DEFINE_STATIC_LOCAL(RefPtr<Image>, nullImage, (BitmapImage::create()));;
    61     return nullImage.get();
     60    static Image* nullImage = BitmapImage::create().leakRef();
     61    return nullImage;
    6262}
    6363
  • trunk/Source/WebCore/platform/graphics/PlatformTextTrack.h

    r151853 r154023  
    7777    static PlatformTextTrack* captionMenuOffItem()
    7878    {
    79         DEFINE_STATIC_LOCAL(RefPtr<PlatformTextTrack>, off, (PlatformTextTrack::create(0, "off menu item", "", Subtitle, InBand, 0)));
    80         return off.get();
     79        static PlatformTextTrack* off = PlatformTextTrack::create(0, "off menu item", "", Subtitle, InBand, 0).leakRef();
     80        return off;
    8181    }
    8282
    8383    static PlatformTextTrack* captionMenuAutomaticItem()
    8484    {
    85         DEFINE_STATIC_LOCAL(RefPtr<PlatformTextTrack>, automatic, (PlatformTextTrack::create(0, "automatic menu item", "", Subtitle, InBand, 0)));
    86         return automatic.get();
     85        static PlatformTextTrack *automatic = PlatformTextTrack::create(0, "automatic menu item", "", Subtitle, InBand, 0).leakRef();
     86        return automatic;
    8787    }
    8888
  • trunk/Source/WebCore/rendering/style/RenderStyle.cpp

    r153906 r154023  
    17871787ShapeValue* RenderStyle::initialShapeInside()
    17881788{
    1789     DEFINE_STATIC_LOCAL(RefPtr<ShapeValue>, sOutsideValue, (ShapeValue::createOutsideValue()));
    1790     return sOutsideValue.get();
     1789    static ShapeValue* outsideValue = ShapeValue::createOutsideValue().leakRef();
     1790    return outsideValue;
    17911791}
    17921792#endif
  • trunk/Source/WebCore/testing/MockCDM.cpp

    r153838 r154023  
    7676static Uint8Array* initDataPrefix()
    7777{
    78     static const unsigned char prefixData[] = {'m', 'o', 'c', 'k'};
    79     DEFINE_STATIC_LOCAL(RefPtr<Uint8Array>, prefix, ());
    80     static bool initialized = false;
    81     if (!initialized) {
    82         initialized = true;
    83         prefix = Uint8Array::create(prefixData, sizeof(prefixData) / sizeof(prefixData[0]));
    84     }
    85     return prefix.get();
     78    const unsigned char prefixData[] = { 'm', 'o', 'c', 'k' };
     79    static Uint8Array* prefix = Uint8Array::create(prefixData, WTF_ARRAY_LENGTH(prefixData)).leakRef();
     80
     81    return prefix;
    8682}
    8783
     
    8985{
    9086    static const unsigned char prefixData[] = {'k', 'e', 'y'};
    91     DEFINE_STATIC_LOCAL(RefPtr<JSC::Uint8Array>, prefix, ());
    92     static bool initialized = false;
    93     if (!initialized) {
    94         initialized = true;
    95         prefix = Uint8Array::create(prefixData, sizeof(prefixData) / sizeof(prefixData[0]));
    96     }
    97     return prefix.get();
     87    static Uint8Array* prefix = Uint8Array::create(prefixData, WTF_ARRAY_LENGTH(prefixData)).leakRef();
     88
     89    return prefix;
    9890}
    9991
     
    10193{
    10294    static const unsigned char requestData[] = {'r', 'e', 'q', 'u', 'e', 's', 't'};
    103     DEFINE_STATIC_LOCAL(RefPtr<JSC::Uint8Array>, request, ());
    104     static bool initialized = false;
    105     if (!initialized) {
    106         initialized = true;
    107         request = Uint8Array::create(requestData, sizeof(requestData) / sizeof(requestData[0]));
    108     }
    109     return request.get();
     95    static Uint8Array* request = Uint8Array::create(requestData, WTF_ARRAY_LENGTH(requestData)).leakRef();
     96
     97    return request;
    11098}
    11199
Note: See TracChangeset for help on using the changeset viewer.