Title: [182535] trunk/Source/_javascript_Core
Revision
182535
Author
[email protected]
Date
2015-04-08 07:03:26 -0700 (Wed, 08 Apr 2015)

Log Message

Lazily initialize LogToSystemConsole flag to reduce memory usage
https://bugs.webkit.org/show_bug.cgi?id=143506

Reviewed by Mark Lam.

Only call into CF preferences code when we need to in order to reduce memory usage.

* inspector/JSGlobalObjectConsoleClient.cpp:
(Inspector::JSGlobalObjectConsoleClient::logToSystemConsole):
(Inspector::JSGlobalObjectConsoleClient::setLogToSystemConsole):
(Inspector::JSGlobalObjectConsoleClient::initializeLogToSystemConsole):
(Inspector::JSGlobalObjectConsoleClient::JSGlobalObjectConsoleClient):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (182534 => 182535)


--- trunk/Source/_javascript_Core/ChangeLog	2015-04-08 10:32:24 UTC (rev 182534)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-04-08 14:03:26 UTC (rev 182535)
@@ -1,3 +1,18 @@
+2015-04-07  Michael Saboff  <[email protected]>
+
+        Lazily initialize LogToSystemConsole flag to reduce memory usage
+        https://bugs.webkit.org/show_bug.cgi?id=143506
+
+        Reviewed by Mark Lam.
+
+        Only call into CF preferences code when we need to in order to reduce memory usage.
+
+        * inspector/JSGlobalObjectConsoleClient.cpp:
+        (Inspector::JSGlobalObjectConsoleClient::logToSystemConsole):
+        (Inspector::JSGlobalObjectConsoleClient::setLogToSystemConsole):
+        (Inspector::JSGlobalObjectConsoleClient::initializeLogToSystemConsole):
+        (Inspector::JSGlobalObjectConsoleClient::JSGlobalObjectConsoleClient):
+
 2015-04-07  Benjamin Poulain  <[email protected]>
 
         Get the features.json files ready for open contributions

Modified: trunk/Source/_javascript_Core/inspector/JSGlobalObjectConsoleClient.cpp (182534 => 182535)


--- trunk/Source/_javascript_Core/inspector/JSGlobalObjectConsoleClient.cpp	2015-04-08 10:32:24 UTC (rev 182534)
+++ trunk/Source/_javascript_Core/inspector/JSGlobalObjectConsoleClient.cpp	2015-04-08 14:03:26 UTC (rev 182535)
@@ -41,19 +41,31 @@
 namespace Inspector {
 
 static bool sLogToSystemConsole = false;
+static bool sSetLogToSystemConsole = false;
 
 bool JSGlobalObjectConsoleClient::logToSystemConsole()
 {
+    if (!sSetLogToSystemConsole) {
+        static std::once_flag initializeLogging;
+        std::call_once(initializeLogging, []{
+            JSGlobalObjectConsoleClient::initializeLogToSystemConsole();
+        });
+    }
     return sLogToSystemConsole;
 }
 
 void JSGlobalObjectConsoleClient::setLogToSystemConsole(bool shouldLog)
 {
+    sSetLogToSystemConsole = true;
     sLogToSystemConsole = shouldLog;
 }
 
 void JSGlobalObjectConsoleClient::initializeLogToSystemConsole()
 {
+    // If setLogToSystemConsole() was called, no need to query the default value.
+    if (sSetLogToSystemConsole)
+        return;
+
 #if !LOG_DISABLED
     sLogToSystemConsole = true;
 #elif USE(CF)
@@ -62,16 +74,13 @@
     if (keyExistsAndHasValidFormat)
         sLogToSystemConsole = preference;
 #endif
+    sSetLogToSystemConsole = true;
 }
 
 JSGlobalObjectConsoleClient::JSGlobalObjectConsoleClient(InspectorConsoleAgent* consoleAgent)
     : ConsoleClient()
     , m_consoleAgent(consoleAgent)
 {
-    static std::once_flag initializeLogging;
-    std::call_once(initializeLogging, []{
-        JSGlobalObjectConsoleClient::initializeLogToSystemConsole();
-    });
 }
 
 void JSGlobalObjectConsoleClient::messageWithTypeAndLevel(MessageType type, MessageLevel level, JSC::ExecState* exec, RefPtr<ScriptArguments>&& arguments)

Modified: trunk/Source/_javascript_Core/inspector/JSGlobalObjectConsoleClient.h (182534 => 182535)


--- trunk/Source/_javascript_Core/inspector/JSGlobalObjectConsoleClient.h	2015-04-08 10:32:24 UTC (rev 182534)
+++ trunk/Source/_javascript_Core/inspector/JSGlobalObjectConsoleClient.h	2015-04-08 14:03:26 UTC (rev 182535)
@@ -40,7 +40,6 @@
 
     static bool logToSystemConsole();
     static void setLogToSystemConsole(bool);
-    static void initializeLogToSystemConsole();
 
 protected:
     virtual void messageWithTypeAndLevel(MessageType, MessageLevel, JSC::ExecState*, RefPtr<ScriptArguments>&&) override;
@@ -52,6 +51,8 @@
     virtual void timeStamp(JSC::ExecState*, RefPtr<ScriptArguments>&&) override;
 
 private:
+    static void initializeLogToSystemConsole();
+
     void warnUnimplemented(const String& method);
     void internalAddMessage(MessageType, MessageLevel, JSC::ExecState*, RefPtr<ScriptArguments>&&);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to