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

Fix tojson unconditionally serializes #26054

Merged
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

fixed is_satisfied condition

  • Loading branch information
shnmorimoto committed Mar 29, 2020
commit d8c1dc60e8f48f05ecd3ec01fbc91d7743734460
@@ -2976,22 +2976,24 @@ def definition_body(self):
ret_conditions = 'vec![' + ",".join(conditions) + "]"

This comment has been minimized.

@jdm

jdm Mar 30, 2020

Member

Let's use &[ instead of vec![ to avoid allocating a bunch of memory needlessly. Also use ", " when joining to make the resulting code a bit easier to read.

This comment has been minimized.

@shnmorimoto

shnmorimoto Mar 31, 2020

Author Contributor

thanks! fixed 74995a5

ret += fill(
"""
let incumbent_global = GlobalScope::incumbent().expect("no incumbent global");
let global = incumbent_global.reflector().get_jsobject();
Comment on lines +2979 to +2980

This comment has been minimized.

@jdm

jdm Mar 30, 2020

Member

We can move these to the initial definition of ret so that we only get the global object once at the start of the method.

This comment has been minimized.

@shnmorimoto

shnmorimoto Mar 31, 2020

Author Contributor

Thanks for the review. fixed 74995a5

let conditions = ${conditions};
if !conditions.iter().any(|c|
let is_satisfied = conditions.iter().any(|c|
c.is_satisfied(
SafeJSContext::from_ptr(cx),
HandleObject::from_raw(obj),
HandleObject::from_raw(obj))) {
return false;
}
rooted!(in(cx) let mut temp = UndefinedValue());
if !get_${name}(cx, obj, this, JSJitGetterCallArgs { _base: temp.handle_mut().into() }) {
return false;
}
if !JS_DefineProperty(cx, result.handle().into(),
${nameAsArray} as *const u8 as *const libc::c_char,
temp.handle(), JSPROP_ENUMERATE as u32) {
return false;
global));
if is_satisfied {
rooted!(in(cx) let mut temp = UndefinedValue());
if !get_${name}(cx, obj, this, JSJitGetterCallArgs { _base: temp.handle_mut().into() }) {
return false;
}
if !JS_DefineProperty(cx, result.handle().into(),
${nameAsArray} as *const u8 as *const libc::c_char,
temp.handle(), JSPROP_ENUMERATE as u32) {
return false;
}
}
""",
name=name, nameAsArray=str_to_const_array(name), conditions=ret_conditions)
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.