Title: [125992] trunk/Source/WebCore
Revision
125992
Author
[email protected]
Date
2012-08-19 21:03:24 -0700 (Sun, 19 Aug 2012)

Log Message

Do not allocate SQLiteDatabase's m_openErrorMessage until its needed
https://bugs.webkit.org/show_bug.cgi?id=94434

Reviewed by Andreas Kling.

Previously, m_openErrorMessage was initialized from a static literal string whenever
the database is not open.

This patch changes the way we use m_openErrorMessage to only allocate a string in the
few cases where we need it. If there is no error message, we fallback to the previous
default string.

The goal is to prevent allocating the string unless needed. That saves initialization time
and memory.

* platform/sql/SQLiteDatabase.cpp:
(WebCore::SQLiteDatabase::SQLiteDatabase):
(WebCore::SQLiteDatabase::close):
(WebCore::SQLiteDatabase::lastErrorMsg):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (125991 => 125992)


--- trunk/Source/WebCore/ChangeLog	2012-08-20 03:44:23 UTC (rev 125991)
+++ trunk/Source/WebCore/ChangeLog	2012-08-20 04:03:24 UTC (rev 125992)
@@ -1,5 +1,27 @@
 2012-08-19  Benjamin Poulain  <[email protected]>
 
+        Do not allocate SQLiteDatabase's m_openErrorMessage until its needed
+        https://bugs.webkit.org/show_bug.cgi?id=94434
+
+        Reviewed by Andreas Kling.
+
+        Previously, m_openErrorMessage was initialized from a static literal string whenever
+        the database is not open.
+
+        This patch changes the way we use m_openErrorMessage to only allocate a string in the
+        few cases where we need it. If there is no error message, we fallback to the previous
+        default string.
+
+        The goal is to prevent allocating the string unless needed. That saves initialization time
+        and memory.
+
+        * platform/sql/SQLiteDatabase.cpp:
+        (WebCore::SQLiteDatabase::SQLiteDatabase):
+        (WebCore::SQLiteDatabase::close):
+        (WebCore::SQLiteDatabase::lastErrorMsg):
+
+2012-08-19  Benjamin Poulain  <[email protected]>
+
         Use initialization from literal for HTML Input type names
         https://bugs.webkit.org/show_bug.cgi?id=94421
 

Modified: trunk/Source/WebCore/platform/sql/SQLiteDatabase.cpp (125991 => 125992)


--- trunk/Source/WebCore/platform/sql/SQLiteDatabase.cpp	2012-08-20 03:44:23 UTC (rev 125991)
+++ trunk/Source/WebCore/platform/sql/SQLiteDatabase.cpp	2012-08-20 04:03:24 UTC (rev 125992)
@@ -56,7 +56,7 @@
     , m_openingThread(0)
     , m_interrupted(false)
     , m_openError(SQLITE_ERROR)
-    , m_openErrorMessage(notOpenErrorMessage)
+    , m_openErrorMessage()
 {
 }
 
@@ -114,7 +114,7 @@
 
     m_openingThread = 0;
     m_openError = SQLITE_ERROR;
-    m_openErrorMessage = notOpenErrorMessage;
+    m_openErrorMessage = CString();
 }
 
 void SQLiteDatabase::interrupt()
@@ -333,8 +333,10 @@
 }
 
 const char* SQLiteDatabase::lastErrorMsg()
-{ 
-    return m_db ? sqlite3_errmsg(m_db) : m_openErrorMessage.data();
+{
+    if (m_db)
+        return sqlite3_errmsg(m_db);
+    return m_openErrorMessage.isNull() ? notOpenErrorMessage : m_openErrorMessage.data();
 }
 
 #ifndef NDEBUG
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to