Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Low hanging Dromaeo fruit #6900

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

script: Stop reallocating so much when converting DOM strings to JS

values.

`size_hint()` in `utf16_units()` seems busted, so we do it ourselves.
  • Loading branch information
pcwalton committed Sep 17, 2015
commit 2f0702609c30c2834d5c506dfc113235a2a0aaff
@@ -399,8 +399,9 @@ impl<T: Float + FromJSValConvertible<Config=()>> FromJSValConvertible for Finite

impl ToJSValConvertible for str {
fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
let mut string_utf16: Vec<u16> = Vec::with_capacity(self.len());
unsafe {
let string_utf16: Vec<u16> = self.utf16_units().collect();
string_utf16.extend(self.utf16_units());
let jsstr = JS_NewUCStringCopyN(cx, string_utf16.as_ptr() as *const i16,
string_utf16.len() as libc::size_t);
if jsstr.is_null() {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.