Title: [123547] trunk/Source/WebCore
Revision
123547
Author
[email protected]
Date
2012-07-24 16:12:35 -0700 (Tue, 24 Jul 2012)

Log Message

Unreviewed, rolling out r123191.
http://trac.webkit.org/changeset/123191
https://bugs.webkit.org/show_bug.cgi?id=91804

It might cause another performance regression.
http://code.google.com/p/chromium/issues/detail?id=138410

* html/FormController.cpp:
(FormKeyGenerator):
(WebCore::createKey):
(WebCore::FormKeyGenerator::formKey):
(WebCore::FormKeyGenerator::willDeleteForm):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (123546 => 123547)


--- trunk/Source/WebCore/ChangeLog	2012-07-24 22:55:34 UTC (rev 123546)
+++ trunk/Source/WebCore/ChangeLog	2012-07-24 23:12:35 UTC (rev 123547)
@@ -1,3 +1,18 @@
+2012-07-24  Kent Tamura  <[email protected]>
+
+        Unreviewed, rolling out r123191.
+        http://trac.webkit.org/changeset/123191
+        https://bugs.webkit.org/show_bug.cgi?id=91804
+
+        It might cause another performance regression.
+        http://code.google.com/p/chromium/issues/detail?id=138410
+
+        * html/FormController.cpp:
+        (FormKeyGenerator):
+        (WebCore::createKey):
+        (WebCore::FormKeyGenerator::formKey):
+        (WebCore::FormKeyGenerator::willDeleteForm):
+
 2012-07-24  Vineet Chaudhary  <[email protected]>
 
         [JSBinding] Merging jsUnsignedLongArrayToVector() to toNativeArray() using traits.

Modified: trunk/Source/WebCore/html/FormController.cpp (123546 => 123547)


--- trunk/Source/WebCore/html/FormController.cpp	2012-07-24 22:55:34 UTC (rev 123546)
+++ trunk/Source/WebCore/html/FormController.cpp	2012-07-24 23:12:35 UTC (rev 123547)
@@ -278,9 +278,8 @@
     FormKeyGenerator() { }
 
     typedef HashMap<HTMLFormElement*, AtomicString> FormToKeyMap;
-    typedef HashMap<String, unsigned> FormSignatureToNextIndexMap;
     FormToKeyMap m_formToKeyMap;
-    FormSignatureToNextIndexMap m_formSignatureToNextIndexMap;
+    HashSet<AtomicString> m_existingKeys;
 };
 
 static inline void recordFormStructure(const HTMLFormElement& form, StringBuilder& builder)
@@ -305,9 +304,10 @@
     builder.append("]");
 }
 
-static inline String formSignature(const HTMLFormElement& form)
+static inline AtomicString createKey(HTMLFormElement* form, unsigned index)
 {
-    KURL actionURL = form.getURLAttribute(actionAttr);
+    ASSERT(form);
+    KURL actionURL = form->getURLAttribute(actionAttr);
     // Remove the query part because it might contain volatile parameters such
     // as a session key.
     actionURL.setQuery(String());
@@ -315,8 +315,11 @@
     if (!actionURL.isEmpty())
         builder.append(actionURL.string());
 
-    recordFormStructure(form, builder);
-    return builder.toString();
+    recordFormStructure(*form, builder);
+
+    builder.append(" #");
+    builder.append(String::number(index));
+    return builder.toAtomicString();
 }
 
 AtomicString FormKeyGenerator::formKey(const HTMLFormControlElementWithState& control)
@@ -330,18 +333,13 @@
     if (it != m_formToKeyMap.end())
         return it->second;
 
-    String signature = formSignature(*form);
-    ASSERT(!signature.isNull());
-    FormSignatureToNextIndexMap::AddResult result = m_formSignatureToNextIndexMap.add(signature, 0);
-    unsigned nextIndex = result.iterator->second++;
-
-    StringBuilder builder;
-    builder.append(signature);
-    builder.append(" #");
-    builder.append(String::number(nextIndex));
-    AtomicString formKey = builder.toAtomicString();
-    m_formToKeyMap.add(form, formKey);
-    return formKey;
+    AtomicString candidateKey;
+    unsigned index = 0;
+    do {
+        candidateKey = createKey(form, index++);
+    } while (!m_existingKeys.add(candidateKey).isNewEntry);
+    m_formToKeyMap.add(form, candidateKey);
+    return candidateKey;
 }
 
 void FormKeyGenerator::willDeleteForm(HTMLFormElement* form)
@@ -352,6 +350,7 @@
     FormToKeyMap::iterator it = m_formToKeyMap.find(form);
     if (it == m_formToKeyMap.end())
         return;
+    m_existingKeys.remove(it->second);
     m_formToKeyMap.remove(it);
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to