Changeset 128126 in webkit
- Timestamp:
- Sep 10, 2012 4:23:00 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r128125 r128126 1 2012-09-10 Adam Barth <abarth@chromium.org> 2 3 [V8] V8LazyEventListener::prepareListenerObject uses inefficient string operations 4 https://bugs.webkit.org/show_bug.cgi?id=96324 5 6 Reviewed by Kentaro Hara. 7 8 Previously, this code called String::append several times, which 9 mallocs a new string buffer each time. This patch switches this code to 10 use operator+, which uses StringAppend to optimize these operations 11 down to a single malloc. 12 13 * bindings/v8/V8LazyEventListener.cpp: 14 (WebCore::V8LazyEventListener::prepareListenerObject): 15 1 16 2012-09-10 Adam Barth <abarth@chromium.org> 2 17 -
trunk/Source/WebCore/bindings/v8/V8LazyEventListener.cpp
r126967 r128126 146 146 // By calling the function with 4 arguments, we create a setter on arguments object 147 147 // which would shadow property "3" on the prototype. 148 String code = ASCIILiteral("(function() {" \ 149 "with (this[2]) {" \ 150 "with (this[1]) {" \ 151 "with (this[0]) {"); 152 code.append("return function("); 153 code.append(m_eventParameterName); 154 code.append(") {"); 155 code.append(m_code); 156 // Insert '\n' otherwise //-style comments could break the handler. 157 code.append("\n};}}}})"); 148 String code = "(function() {" 149 "with (this[2]) {" 150 "with (this[1]) {" 151 "with (this[0]) {" 152 "return function(" + m_eventParameterName + ") {" + 153 m_code + "\n" // Insert '\n' otherwise //-style comments could break the handler. 154 "};" 155 "}}}})"; 156 158 157 v8::Handle<v8::String> codeExternalString = v8ExternalString(code); 159 158 … … 220 219 toStringFunction = toStringTemplate->GetFunction(); 221 220 if (!toStringFunction.IsEmpty()) { 222 String toStringResult = ASCIILiteral("function "); 223 toStringResult.append(m_functionName); 224 toStringResult.append("("); 225 toStringResult.append(m_eventParameterName); 226 toStringResult.append(") {\n "); 227 toStringResult.append(m_code); 228 toStringResult.append("\n}"); 229 wrappedFunction->SetHiddenValue(V8HiddenPropertyName::toStringString(), v8ExternalString(toStringResult)); 221 String toStringString = "function " + m_functionName + "(" + m_eventParameterName + ") {\n " + m_code + "\n}"; 222 wrappedFunction->SetHiddenValue(V8HiddenPropertyName::toStringString(), v8ExternalString(toStringString)); 230 223 wrappedFunction->Set(v8::String::NewSymbol("toString"), toStringFunction); 231 224 }
Note: See TracChangeset
for help on using the changeset viewer.