Title: [149854] trunk/Source/WebCore
Revision
149854
Author
ander...@apple.com
Date
2013-05-09 16:41:26 -0700 (Thu, 09 May 2013)

Log Message

Clean up SecurityOrigin::databaseIdentifier
https://bugs.webkit.org/show_bug.cgi?id=115882

Reviewed by Beth Dakin.

Remove m_encodedHost and just call encodeHost from databaseIdentifier().
Also, use a StringBuilder when constructing the database identifier to avoid allocating
temporary String objects over and over.

* page/SecurityOrigin.cpp:
(WebCore::SecurityOrigin::SecurityOrigin):
(WebCore):
(WebCore::SecurityOrigin::createFromDatabaseIdentifier):
(WebCore::SecurityOrigin::databaseIdentifier):
* page/SecurityOrigin.h:
(SecurityOrigin):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (149853 => 149854)


--- trunk/Source/WebCore/ChangeLog	2013-05-09 23:21:25 UTC (rev 149853)
+++ trunk/Source/WebCore/ChangeLog	2013-05-09 23:41:26 UTC (rev 149854)
@@ -1,5 +1,24 @@
 2013-05-09  Anders Carlsson  <ander...@apple.com>
 
+        Clean up SecurityOrigin::databaseIdentifier
+        https://bugs.webkit.org/show_bug.cgi?id=115882
+
+        Reviewed by Beth Dakin.
+
+        Remove m_encodedHost and just call encodeHost from databaseIdentifier().
+        Also, use a StringBuilder when constructing the database identifier to avoid allocating
+        temporary String objects over and over.
+
+        * page/SecurityOrigin.cpp:
+        (WebCore::SecurityOrigin::SecurityOrigin):
+        (WebCore):
+        (WebCore::SecurityOrigin::createFromDatabaseIdentifier):
+        (WebCore::SecurityOrigin::databaseIdentifier):
+        * page/SecurityOrigin.h:
+        (SecurityOrigin):
+
+2013-05-09  Anders Carlsson  <ander...@apple.com>
+
         Remove m_securityOrigin from XMLHttpRequest
         https://bugs.webkit.org/show_bug.cgi?id=115881
 

Modified: trunk/Source/WebCore/page/SecurityOrigin.cpp (149853 => 149854)


--- trunk/Source/WebCore/page/SecurityOrigin.cpp	2013-05-09 23:21:25 UTC (rev 149853)
+++ trunk/Source/WebCore/page/SecurityOrigin.cpp	2013-05-09 23:41:26 UTC (rev 149854)
@@ -159,7 +159,6 @@
 SecurityOrigin::SecurityOrigin(const SecurityOrigin* other)
     : m_protocol(other->m_protocol.isolatedCopy())
     , m_host(other->m_host.isolatedCopy())
-    , m_encodedHost(other->m_encodedHost.isolatedCopy())
     , m_domain(other->m_domain.isolatedCopy())
     , m_filePath(other->m_filePath.isolatedCopy())
     , m_port(other->m_port)
@@ -497,17 +496,17 @@
     return SecurityOrigin::create(KURL(KURL(), originString));
 }
 
-static const char SeparatorCharacter = '_';
+static const char separatorCharacter = '_';
 
 PassRefPtr<SecurityOrigin> SecurityOrigin::createFromDatabaseIdentifier(const String& databaseIdentifier)
 { 
     // Make sure there's a first separator
-    size_t separator1 = databaseIdentifier.find(SeparatorCharacter);
+    size_t separator1 = databaseIdentifier.find(separatorCharacter);
     if (separator1 == notFound)
         return create(KURL());
         
     // Make sure there's a second separator
-    size_t separator2 = databaseIdentifier.reverseFind(SeparatorCharacter);
+    size_t separator2 = databaseIdentifier.reverseFind(separatorCharacter);
     if (separator2 == notFound)
         return create(KURL());
         
@@ -552,12 +551,14 @@
     if (m_needsDatabaseIdentifierQuirkForFiles)
         return "file__0";
 
-    String separatorString(&SeparatorCharacter, 1);
+    StringBuilder stringBuilder;
+    stringBuilder.append(m_protocol);
+    stringBuilder.append(separatorCharacter);
+    stringBuilder.append(encodeForFileName(m_host));
+    stringBuilder.append(separatorCharacter);
+    stringBuilder.appendNumber(m_port);
 
-    if (m_encodedHost.isEmpty())
-        m_encodedHost = encodeForFileName(m_host);
-
-    return m_protocol + separatorString + m_encodedHost + separatorString + String::number(m_port); 
+    return stringBuilder.toString();
 }
 
 bool SecurityOrigin::equal(const SecurityOrigin* other) const 

Modified: trunk/Source/WebCore/page/SecurityOrigin.h (149853 => 149854)


--- trunk/Source/WebCore/page/SecurityOrigin.h	2013-05-09 23:21:25 UTC (rev 149853)
+++ trunk/Source/WebCore/page/SecurityOrigin.h	2013-05-09 23:41:26 UTC (rev 149854)
@@ -223,7 +223,6 @@
 
     String m_protocol;
     String m_host;
-    mutable String m_encodedHost;
     String m_domain;
     String m_filePath;
     unsigned short m_port;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to