Skip to content

Commit

Permalink
boxed: Remove unnecessary roots
Browse files Browse the repository at this point in the history
  • Loading branch information
ptomato authored and jaszhix committed Aug 1, 2018
1 parent a8b578d commit 90992e1
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions gi/boxed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ boxed_init_from_props(JSContext *context,
priv->field_map = get_field_map(priv->info);

JS::RootedValue value(context);
JS::RootedId prop_id(context);
for (ix = 0, length = ids.length(); ix < length; ix++) {
GIFieldInfo *field_info;
GjsAutoJSChar name;
Expand All @@ -285,9 +284,9 @@ boxed_init_from_props(JSContext *context,

/* ids[ix] is reachable because props is rooted, but require_property
* doesn't know that */
prop_id = ids[ix];
if (!gjs_object_require_property(context, props, "property list",
prop_id, &value))
JS::HandleId::fromMarkedLocation(ids[ix].address()),
&value))
return false;

if (!boxed_set_field_from_value(context, priv, field_info, value))
Expand Down Expand Up @@ -366,15 +365,14 @@ boxed_new(JSContext *context,
} else if (priv->can_allocate_directly) {
boxed_new_direct(priv);
} else if (priv->default_constructor >= 0) {
bool retval;

/* for simplicity, we simply delegate all the work to the actual JS constructor
function (which we retrieve from the JS constructor, that is, Namespace.BoxedType,
or object.constructor, given that object was created with the right prototype */
JS::RootedId default_constructor_name(context, priv->default_constructor_name);
retval = boxed_invoke_constructor(context, obj,
default_constructor_name, args);
return retval;
/* for simplicity, we simply delegate all the work to the actual JS
* constructor function (which we retrieve from the JS constructor,
* that is, Namespace.BoxedType, or object.constructor, given that
* object was created with the right prototype. The ID is traced from
* the object, so it's OK to create a handle from it. */
return boxed_invoke_constructor(context, obj,
JS::HandleId::fromMarkedLocation(priv->default_constructor_name.address()),
args);
} else {
gjs_throw(context, "Unable to construct struct type %s since it has no default constructor and cannot be allocated directly",
g_base_info_get_name((GIBaseInfo*) priv->info));
Expand Down

0 comments on commit 90992e1

Please sign in to comment.