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

[Merged by Bors] - Don't construct prototype if not needed #2751

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions boa_engine/src/vm/code_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,25 +613,25 @@ pub(crate) fn create_function_object(
.configurable(true)
.build();

let prototype = JsObject::with_object_proto(context);
prototype
.define_property_or_throw(CONSTRUCTOR, constructor_property, context)
.expect("failed to define the constructor property of the function");

let prototype_property = PropertyDescriptor::builder()
.value(prototype)
.writable(true)
.enumerable(false)
.configurable(false)
.build();

constructor
.define_property_or_throw(utf16!("length"), length_property, context)
.expect("failed to define the length property of the function");
constructor
.define_property_or_throw(utf16!("name"), name_property, context)
.expect("failed to define the name property of the function");

if !r#async && !arrow && !method {
let prototype = JsObject::with_object_proto(context);
prototype
.define_property_or_throw(CONSTRUCTOR, constructor_property, context)
.expect("failed to define the constructor property of the function");

let prototype_property = PropertyDescriptor::builder()
.value(prototype)
.writable(true)
.enumerable(false)
.configurable(false)
.build();
constructor
.define_property_or_throw(PROTOTYPE, prototype_property, context)
.expect("failed to define the prototype property of the function");
Expand Down