Changeset 184866 in webkit for trunk/Source/JavaScriptCore
- Timestamp:
- May 26, 2015, 11:56:42 AM (10 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r184865 r184866 1 2015-05-26 Andreas Kling <[email protected]> 2 3 String.prototype.charCodeAt() should use StringView. 4 <https://webkit.org/b/145353> 5 6 Reviewed by Darin Adler. 7 8 Use JSString::view() in charCodeAt() to avoid reifying the JSString if it's 9 a substring. This avoids StringImpl allocation in some cases and ref churn 10 in all cases. 11 12 * runtime/StringPrototype.cpp: 13 (JSC::stringProtoFuncCharCodeAt): 14 1 15 2015-05-26 Andreas Kling <[email protected]> 2 16 -
trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp
r184865 r184866 805 805 if (!checkObjectCoercible(thisValue)) 806 806 return throwVMTypeError(exec); 807 String s = thisValue.toString(exec)->value(exec); 808 unsigned len = s.length(); 807 StringView string = thisValue.toString(exec)->view(exec); 809 808 JSValue a0 = exec->argument(0); 810 809 if (a0.isUInt32()) { 811 810 uint32_t i = a0.asUInt32(); 812 if (i < len) { 813 if (s.is8Bit()) 814 return JSValue::encode(jsNumber(s.characters8()[i])); 815 return JSValue::encode(jsNumber(s.characters16()[i])); 816 } 811 if (i < string.length()) 812 return JSValue::encode(jsNumber(string[i])); 817 813 return JSValue::encode(jsNaN()); 818 814 } 819 815 double dpos = a0.toInteger(exec); 820 if (dpos >= 0 && dpos < len)821 return JSValue::encode(jsNumber(s [static_cast<int>(dpos)]));816 if (dpos >= 0 && dpos < string.length()) 817 return JSValue::encode(jsNumber(string[static_cast<int>(dpos)])); 822 818 return JSValue::encode(jsNaN()); 823 819 }
Note:
See TracChangeset
for help on using the changeset viewer.