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

refactor(transformer/class-properties): exit transform_class faster if nothing to do #7586

Merged
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
12 changes: 7 additions & 5 deletions crates/oxc_transformer/src/es2022/class_properties/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,13 @@ impl<'a, 'ctx> ClassProperties<'a, 'ctx> {
index_not_including_removed += 1;
}

// Exit if nothing to transform
if instance_prop_count == 0 && !has_static_prop_or_static_block {
self.private_props_stack.push(None);
return;
}

// Add entry to `private_props_stack`
if private_props.is_empty() {
self.private_props_stack.push(None);
} else {
Expand All @@ -353,11 +360,6 @@ impl<'a, 'ctx> ClassProperties<'a, 'ctx> {
}));
}

// Exit if nothing to transform
if instance_prop_count == 0 && !has_static_prop_or_static_block {
return;
}

// Extract properties and static blocks from class body + substitute computed method keys
let mut instance_inits = Vec::with_capacity(instance_prop_count);
class.body.body.retain_mut(|element| {
Expand Down
Loading