Skip to content

Commit

Permalink
remove: unnecessary clone for listbox, checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
ynqa committed May 15, 2024
1 parent 6951a51 commit 4322803
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
10 changes: 3 additions & 7 deletions promkit/src/core/checkbox/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,12 @@ impl PaneFactory for State {
})
.map(|(i, item)| {
if i == self.checkbox.position() {
StyledGraphemes::from_iter([
&StyledGraphemes::from(self.cursor.clone()),
&f(i),
item,
])
.apply_style(self.active_item_style)
StyledGraphemes::from_iter([&StyledGraphemes::from(&self.cursor), &f(i), item])
.apply_style(self.active_item_style)
} else {
StyledGraphemes::from_iter([
&StyledGraphemes::from(
" ".repeat(StyledGraphemes::from(self.cursor.clone()).widths()),
" ".repeat(StyledGraphemes::from(&self.cursor).widths()),
),
&f(i),
item,
Expand Down
4 changes: 2 additions & 2 deletions promkit/src/core/listbox/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ impl PaneFactory for State {
.filter(|(i, _)| *i >= self.listbox.position() && *i < self.listbox.position() + height)
.map(|(i, item)| {
if i == self.listbox.position() {
StyledGraphemes::from_iter([&StyledGraphemes::from(self.cursor.clone()), item])
StyledGraphemes::from_iter([&StyledGraphemes::from(&self.cursor), item])
} else {
let init = StyledGraphemes::from_iter([
&StyledGraphemes::from(
" ".repeat(StyledGraphemes::from(self.cursor.clone()).widths()),
" ".repeat(StyledGraphemes::from(&self.cursor).widths()),
),
item,
]);
Expand Down

0 comments on commit 4322803

Please sign in to comment.