Changeset 154021 in webkit


Ignore:
Timestamp:
Aug 13, 2013 1:58:49 PM (11 years ago)
Author:
andersca@apple.com
Message:

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

Reviewed by Jessie Berlin.

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

  • platform/graphics/mac/ColorMac.mm:

(WebCore::nsColor):

  • platform/graphics/mac/GraphicsContextMac.mm:

(WebCore::makePatternColor):
(WebCore::GraphicsContext::drawLineForDocumentMarker):

  • platform/graphics/mac/SimpleFontDataMac.mm:

(WebCore::webFallbackFontFamily):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r154020 r154021  
     12013-08-13  Anders Carlsson  <andersca@apple.com>
     2
     3        Stop using DEFINE_STATIC_LOCAL with RetainPtr
     4        https://bugs.webkit.org/show_bug.cgi?id=119765
     5
     6        Reviewed by Jessie Berlin.
     7
     8        No need to waste heap memory allocating RetainPtrs, just store the raw pointers directly.
     9
     10        * platform/graphics/mac/ColorMac.mm:
     11        (WebCore::nsColor):
     12        * platform/graphics/mac/GraphicsContextMac.mm:
     13        (WebCore::makePatternColor):
     14        (WebCore::GraphicsContext::drawLineForDocumentMarker):
     15        * platform/graphics/mac/SimpleFontDataMac.mm:
     16        (WebCore::webFallbackFontFamily):
     17
    1182013-08-13  Commit Queue  <commit-queue@webkit.org>
    219
  • trunk/Source/WebCore/platform/graphics/mac/ColorMac.mm

    r150167 r154021  
    7979        case 0: {
    8080            // Need this to avoid returning nil because cachedRGBAValues will default to 0.
    81             DEFINE_STATIC_LOCAL(RetainPtr<NSColor>, clearColor, ([NSColor colorWithDeviceRed:0 green:0 blue:0 alpha:0]));
    82             return clearColor.get();
     81            static NSColor *clearColor = [[NSColor colorWithDeviceRed:0 green:0 blue:0 alpha:0] retain];
     82            return clearColor;
    8383        }
    8484        case Color::black: {
    85             DEFINE_STATIC_LOCAL(RetainPtr<NSColor>, blackColor, ([NSColor colorWithDeviceRed:0 green:0 blue:0 alpha:1]));
    86             return blackColor.get();
     85            static NSColor *blackColor = [[NSColor colorWithDeviceRed:0 green:0 blue:0 alpha:1] retain];
     86            return blackColor;
    8787        }
    8888        case Color::white: {
    89             DEFINE_STATIC_LOCAL(RetainPtr<NSColor>, whiteColor, ([NSColor colorWithDeviceRed:1 green:1 blue:1 alpha:1]));
    90             return whiteColor.get();
     89            static NSColor *whiteColor = [[NSColor colorWithDeviceRed:1 green:1 blue:1 alpha:1] retain];
     90            return whiteColor;
    9191        }
    9292        default: {
  • trunk/Source/WebCore/platform/graphics/mac/GraphicsContextMac.mm

    r149255 r154021  
    8484
    8585
    86 static NSColor* createPatternColor(NSString* firstChoiceName, NSString* secondChoiceName, NSColor* defaultColor, bool& usingDot)
     86static NSColor* makePatternColor(NSString* firstChoiceName, NSString* secondChoiceName, NSColor* defaultColor, bool& usingDot)
    8787{
    8888    // Eventually we should be able to get rid of the secondChoiceName. For the time being we need both to keep
     
    117117            // Constants for spelling pattern color.
    118118            static bool usingDotForSpelling = false;
    119             DEFINE_STATIC_LOCAL(RetainPtr<NSColor>, spellingPatternColor, (createPatternColor(@"NSSpellingDot", @"SpellingDot", [NSColor redColor], usingDotForSpelling)));
     119            static NSColor *spellingPatternColor = [makePatternColor(@"NSSpellingDot", @"SpellingDot", [NSColor redColor], usingDotForSpelling) retain];
    120120            usingDot = usingDotForSpelling;
    121             patternColor = spellingPatternColor.get();
     121            patternColor = spellingPatternColor;
    122122            break;
    123123        }
     
    126126            // Constants for grammar pattern color.
    127127            static bool usingDotForGrammar = false;
    128             DEFINE_STATIC_LOCAL(RetainPtr<NSColor>, grammarPatternColor, (createPatternColor(@"NSGrammarDot", @"GrammarDot", [NSColor greenColor], usingDotForGrammar)));
     128            static NSColor *grammarPatternColor = [makePatternColor(@"NSGrammarDot", @"GrammarDot", [NSColor greenColor], usingDotForGrammar) retain];
    129129            usingDot = usingDotForGrammar;
    130             patternColor = grammarPatternColor.get();
     130            patternColor = grammarPatternColor;
    131131            break;
    132132        }
     
    138138            // Constants for spelling pattern color.
    139139            static bool usingDotForSpelling = false;
    140             DEFINE_STATIC_LOCAL(RetainPtr<NSColor>, spellingPatternColor, (createPatternColor(@"NSCorrectionDot", @"CorrectionDot", [NSColor blueColor], usingDotForSpelling)));
     140            static NSColor *spellingPatternColor = [makePatternColor(@"NSCorrectionDot", @"CorrectionDot", [NSColor blueColor], usingDotForSpelling) retain];
    141141            usingDot = usingDotForSpelling;
    142             patternColor = spellingPatternColor.get();
     142            patternColor = spellingPatternColor;
    143143            break;
    144144        }
  • trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm

    r149980 r154021  
    7575static NSString *webFallbackFontFamily(void)
    7676{
    77     DEFINE_STATIC_LOCAL(RetainPtr<NSString>, webFallbackFontFamily, ([[NSFont systemFontOfSize:16.0f] familyName]));
    78     return webFallbackFontFamily.get();
     77    static NSString *webFallbackFontFamily = [[[NSFont systemFontOfSize:16.0f] familyName] retain];
     78    return webFallbackFontFamily;
    7979}
    8080
Note: See TracChangeset for help on using the changeset viewer.