Skip to content

Commit

Permalink
Replace a use of clone() + assignment with std::mem::take().
Browse files Browse the repository at this point in the history
  • Loading branch information
dyoo committed Nov 14, 2023
1 parent 23545ef commit 7ae1614
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions i18n-helpers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,6 @@ pub fn group_events<'a>(events: &'a [(usize, Event<'a>)]) -> Vec<Group<'a>> {
..self
}
}
fn clear_translator_comments(self) -> Self {
Self {
translator_comments: vec![],
..self
}
}
}

#[derive(Debug)]
Expand All @@ -238,7 +232,7 @@ pub fn group_events<'a>(events: &'a [(usize, Event<'a>)]) -> Vec<Group<'a>> {
self,
idx: usize,
events: &'a [(usize, Event<'a>)],
ctx: GroupingContext,
mut ctx: GroupingContext,
) -> (Vec<Group<'a>>, GroupingContext) {
match self {
State::Translate(start) => {
Expand All @@ -257,10 +251,12 @@ pub fn group_events<'a>(events: &'a [(usize, Event<'a>)]) -> Vec<Group<'a>> {
vec![Group::Translate(
events[start..idx].into(),
GroupExtra {
translator_comments: ctx.translator_comments.clone(),
translator_comments: std::mem::take(
&mut ctx.translator_comments,
),
},
)],
ctx.clear_translator_comments(),
ctx,
)
}
}
Expand Down

0 comments on commit 7ae1614

Please sign in to comment.