Title: [154021] trunk/Source/WebCore
Revision
154021
Author
[email protected]
Date
2013-08-13 13:58:49 -0700 (Tue, 13 Aug 2013)

Log 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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (154020 => 154021)


--- trunk/Source/WebCore/ChangeLog	2013-08-13 20:54:48 UTC (rev 154020)
+++ trunk/Source/WebCore/ChangeLog	2013-08-13 20:58:49 UTC (rev 154021)
@@ -1,3 +1,20 @@
+2013-08-13  Anders Carlsson  <[email protected]>
+
+        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):
+
 2013-08-13  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r153925.

Modified: trunk/Source/WebCore/platform/graphics/mac/ColorMac.mm (154020 => 154021)


--- trunk/Source/WebCore/platform/graphics/mac/ColorMac.mm	2013-08-13 20:54:48 UTC (rev 154020)
+++ trunk/Source/WebCore/platform/graphics/mac/ColorMac.mm	2013-08-13 20:58:49 UTC (rev 154021)
@@ -78,16 +78,16 @@
     switch (c) {
         case 0: {
             // Need this to avoid returning nil because cachedRGBAValues will default to 0.
-            DEFINE_STATIC_LOCAL(RetainPtr<NSColor>, clearColor, ([NSColor colorWithDeviceRed:0 green:0 blue:0 alpha:0]));
-            return clearColor.get();
+            static NSColor *clearColor = [[NSColor colorWithDeviceRed:0 green:0 blue:0 alpha:0] retain];
+            return clearColor;
         }
         case Color::black: {
-            DEFINE_STATIC_LOCAL(RetainPtr<NSColor>, blackColor, ([NSColor colorWithDeviceRed:0 green:0 blue:0 alpha:1]));
-            return blackColor.get();
+            static NSColor *blackColor = [[NSColor colorWithDeviceRed:0 green:0 blue:0 alpha:1] retain];
+            return blackColor;
         }
         case Color::white: {
-            DEFINE_STATIC_LOCAL(RetainPtr<NSColor>, whiteColor, ([NSColor colorWithDeviceRed:1 green:1 blue:1 alpha:1]));
-            return whiteColor.get();
+            static NSColor *whiteColor = [[NSColor colorWithDeviceRed:1 green:1 blue:1 alpha:1] retain];
+            return whiteColor;
         }
         default: {
             const int cacheSize = 32;

Modified: trunk/Source/WebCore/platform/graphics/mac/GraphicsContextMac.mm (154020 => 154021)


--- trunk/Source/WebCore/platform/graphics/mac/GraphicsContextMac.mm	2013-08-13 20:54:48 UTC (rev 154020)
+++ trunk/Source/WebCore/platform/graphics/mac/GraphicsContextMac.mm	2013-08-13 20:58:49 UTC (rev 154021)
@@ -83,7 +83,7 @@
 }
 
 
-static NSColor* createPatternColor(NSString* firstChoiceName, NSString* secondChoiceName, NSColor* defaultColor, bool& usingDot)
+static NSColor* makePatternColor(NSString* firstChoiceName, NSString* secondChoiceName, NSColor* defaultColor, bool& usingDot)
 {
     // Eventually we should be able to get rid of the secondChoiceName. For the time being we need both to keep
     // this working on all platforms.
@@ -116,18 +116,18 @@
         {
             // Constants for spelling pattern color.
             static bool usingDotForSpelling = false;
-            DEFINE_STATIC_LOCAL(RetainPtr<NSColor>, spellingPatternColor, (createPatternColor(@"NSSpellingDot", @"SpellingDot", [NSColor redColor], usingDotForSpelling)));
+            static NSColor *spellingPatternColor = [makePatternColor(@"NSSpellingDot", @"SpellingDot", [NSColor redColor], usingDotForSpelling) retain];
             usingDot = usingDotForSpelling;
-            patternColor = spellingPatternColor.get();
+            patternColor = spellingPatternColor;
             break;
         }
         case DocumentMarkerGrammarLineStyle:
         {
             // Constants for grammar pattern color.
             static bool usingDotForGrammar = false;
-            DEFINE_STATIC_LOCAL(RetainPtr<NSColor>, grammarPatternColor, (createPatternColor(@"NSGrammarDot", @"GrammarDot", [NSColor greenColor], usingDotForGrammar)));
+            static NSColor *grammarPatternColor = [makePatternColor(@"NSGrammarDot", @"GrammarDot", [NSColor greenColor], usingDotForGrammar) retain];
             usingDot = usingDotForGrammar;
-            patternColor = grammarPatternColor.get();
+            patternColor = grammarPatternColor;
             break;
         }
 #if PLATFORM(MAC) && (PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070)
@@ -137,9 +137,9 @@
         {
             // Constants for spelling pattern color.
             static bool usingDotForSpelling = false;
-            DEFINE_STATIC_LOCAL(RetainPtr<NSColor>, spellingPatternColor, (createPatternColor(@"NSCorrectionDot", @"CorrectionDot", [NSColor blueColor], usingDotForSpelling)));
+            static NSColor *spellingPatternColor = [makePatternColor(@"NSCorrectionDot", @"CorrectionDot", [NSColor blueColor], usingDotForSpelling) retain];
             usingDot = usingDotForSpelling;
-            patternColor = spellingPatternColor.get();
+            patternColor = spellingPatternColor;
             break;
         }
 #endif

Modified: trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm (154020 => 154021)


--- trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm	2013-08-13 20:54:48 UTC (rev 154020)
+++ trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm	2013-08-13 20:58:49 UTC (rev 154021)
@@ -74,8 +74,8 @@
 
 static NSString *webFallbackFontFamily(void)
 {
-    DEFINE_STATIC_LOCAL(RetainPtr<NSString>, webFallbackFontFamily, ([[NSFont systemFontOfSize:16.0f] familyName]));
-    return webFallbackFontFamily.get();
+    static NSString *webFallbackFontFamily = [[[NSFont systemFontOfSize:16.0f] familyName] retain];
+    return webFallbackFontFamily;
 }
 
 const SimpleFontData* SimpleFontData::getCompositeFontReferenceFontData(NSFont *key) const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to