Skip to content

Commit

Permalink
fix optimizer is_constant
Browse files Browse the repository at this point in the history
  • Loading branch information
Varixo committed Dec 6, 2024
1 parent 3c17163 commit 7f1bfe0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/qwik/src/optimizer/core/benches/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ fn transform_todo_app(b: &mut Bencher) {
input: vec![TransformModuleInput {
code: code.into(),
path: "file.tsx".into(),
dev_path: None,
}],
root_dir: None,
core_module: None,
Expand Down
19 changes: 15 additions & 4 deletions packages/qwik/src/optimizer/core/src/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1787,10 +1787,15 @@ impl<'a> Fold for QwikTransform<'a> {
.last_mut()
.expect("Declaration stack empty!");

let is_qcomponent = self.stack_ctxt.last() == Some(&QCOMPONENT.to_string());

for param in &node.params {
let mut identifiers = vec![];
collect_from_pat(&param.pat, &mut identifiers);
let is_constant = matches!(param.pat, ast::Pat::Ident(_));
let is_identifier = collect_from_pat(&param.pat, &mut identifiers);
let mut is_constant = false;

Check failure on line 1795 in packages/qwik/src/optimizer/core/src/transform.rs

View workflow job for this annotation

GitHub Actions / Build optimizer x86_64-unknown-linux-gnu

`if _ { .. } else { .. }` is an expression
if is_qcomponent {
is_constant = is_identifier;
}
current_scope.extend(
identifiers
.into_iter()
Expand All @@ -1817,10 +1822,16 @@ impl<'a> Fold for QwikTransform<'a> {
.decl_stack
.last_mut()
.expect("Declaration stack empty!");

let is_qcomponent = self.stack_ctxt.last() == Some(&QCOMPONENT.to_string());

for param in &node.params {
let mut identifiers = vec![];
collect_from_pat(param, &mut identifiers);
let is_constant = matches!(param, ast::Pat::Ident(_));
let is_identifier = collect_from_pat(param, &mut identifiers);
let mut is_constant = false;

Check failure on line 1831 in packages/qwik/src/optimizer/core/src/transform.rs

View workflow job for this annotation

GitHub Actions / Build optimizer x86_64-unknown-linux-gnu

`if _ { .. } else { .. }` is an expression
if is_qcomponent {
is_constant = is_identifier;
}
current_scope.extend(
identifiers
.into_iter()
Expand Down

0 comments on commit 7f1bfe0

Please sign in to comment.