Do not allocate Static Strings for Notification::permissionString
authorbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 29 Apr 2013 23:59:38 +0000 (23:59 +0000)
committerbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 29 Apr 2013 23:59:38 +0000 (23:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=115316

Reviewed by Geoffrey Garen.

The code is not nearly hot enough to justify keeping this memory around.

* Modules/notifications/Notification.cpp:
(WebCore::Notification::permission):
(WebCore::Notification::permissionString):
* Modules/notifications/Notification.h:
(Notification):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@149334 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/Modules/notifications/Notification.cpp
Source/WebCore/Modules/notifications/Notification.h

index 29f7aed..a4d4dc4 100644 (file)
@@ -1,3 +1,18 @@
+2013-04-29  Benjamin Poulain  <benjamin@webkit.org>
+
+        Do not allocate Static Strings for Notification::permissionString
+        https://bugs.webkit.org/show_bug.cgi?id=115316
+
+        Reviewed by Geoffrey Garen.
+
+        The code is not nearly hot enough to justify keeping this memory around.
+
+        * Modules/notifications/Notification.cpp:
+        (WebCore::Notification::permission):
+        (WebCore::Notification::permissionString):
+        * Modules/notifications/Notification.h:
+        (Notification):
+
 2013-04-29  Anders Carlsson  <andersca@apple.com>
 
         Remove StorageTracker::originsLoaded
index 1a318e0..481184f 100644 (file)
@@ -226,29 +226,25 @@ void Notification::taskTimerFired(Timer<Notification>* timer)
 
 
 #if ENABLE(NOTIFICATIONS)
-const String& Notification::permission(ScriptExecutionContext* context)
+const String Notification::permission(ScriptExecutionContext* context)
 {
     ASSERT(toDocument(context)->page());
     return permissionString(NotificationController::from(toDocument(context)->page())->client()->checkPermission(context));
 }
 
-const String& Notification::permissionString(NotificationClient::Permission permission)
+const String Notification::permissionString(NotificationClient::Permission permission)
 {
-    DEFINE_STATIC_LOCAL(const String, allowedPermission, (ASCIILiteral("granted")));
-    DEFINE_STATIC_LOCAL(const String, deniedPermission, (ASCIILiteral("denied")));
-    DEFINE_STATIC_LOCAL(const String, defaultPermission, (ASCIILiteral("default")));
-
     switch (permission) {
     case NotificationClient::PermissionAllowed:
-        return allowedPermission;
+        return ASCIILiteral("granted");
     case NotificationClient::PermissionDenied:
-        return deniedPermission;
+        return ASCIILiteral("denied");
     case NotificationClient::PermissionNotAllowed:
-        return defaultPermission;
+        return ASCIILiteral("default");
     }
     
     ASSERT_NOT_REACHED();
-    return deniedPermission;
+    return String();
 }
 
 void Notification::requestPermission(ScriptExecutionContext* context, PassRefPtr<NotificationPermissionCallback> callback)
index feaf1fb..01b7a4c 100644 (file)
@@ -136,8 +136,8 @@ public:
     void finalize();
 
 #if ENABLE(NOTIFICATIONS)
-    static const String& permission(ScriptExecutionContext*);
-    static const String& permissionString(NotificationClient::Permission);
+    static const String permission(ScriptExecutionContext*);
+    static const String permissionString(NotificationClient::Permission);
     static void requestPermission(ScriptExecutionContext*, PassRefPtr<NotificationPermissionCallback> = 0);
 #endif