Skip to content

Commit

Permalink
Reduce clone
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Mar 13, 2023
1 parent 259ccfc commit 0ec6b54
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions packages/next-swc/crates/core/src/server_actions.rs
Expand Up @@ -337,16 +337,17 @@ impl<C: Comments> VisitMut for ServerActions<C> {
.emit();
});
} else if !self.in_action_file {
if f.ident.is_none() {
let action_name = gen_ident(&mut self.ident_cnt);
f.ident = Some(Ident::new(action_name, DUMMY_SP));
}
let ident = match f.ident.as_mut() {
None => {
let action_name = gen_ident(&mut self.ident_cnt);
let ident = Ident::new(action_name, DUMMY_SP);
f.ident.insert(ident)
}
Some(i) => i,
};

let (maybe_new_fn, _) = self.add_action_annotations_and_maybe_hoist(
f.ident.as_mut().unwrap(),
Some(&mut f.function),
None,
);
let (maybe_new_fn, _) =
self.add_action_annotations_and_maybe_hoist(&ident, Some(&mut f.function), None);

if let Some(new_fn) = maybe_new_fn {
f.function = new_fn;
Expand Down

0 comments on commit 0ec6b54

Please sign in to comment.