Skip to content

Commit

Permalink
perf: clippy::needless_pass_by_value (#974)
Browse files Browse the repository at this point in the history
  • Loading branch information
EdJoPaTo authored and joshka committed Mar 4, 2024
1 parent f7f6692 commit 8195f52
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -72,6 +72,7 @@ implicit_clone = "warn"
inefficient_to_string = "warn"
missing_const_for_fn = "warn"
needless_for_each = "warn"
needless_pass_by_value = "warn"
semicolon_if_nothing_returned = "warn"
trivially_copy_pass_by_ref = "warn"
use_self = "warn"
Expand Down
1 change: 1 addition & 0 deletions src/widgets/barchart.rs
Expand Up @@ -306,6 +306,7 @@ impl<'a> BarChart<'a> {
}
}

#[derive(Clone, Copy)]
struct LabelInfo {
group_label_visible: bool,
bar_label_visible: bool,
Expand Down
1 change: 1 addition & 0 deletions src/widgets/canvas/line.rs
Expand Up @@ -115,6 +115,7 @@ mod tests {
use super::Line;
use crate::{assert_buffer_eq, prelude::*, widgets::canvas::Canvas};

#[allow(clippy::needless_pass_by_value)]
#[track_caller]
fn test(line: Line, expected_lines: Vec<&str>) {
let mut buffer = Buffer::empty(Rect::new(0, 0, 10, 10));
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/list.rs
Expand Up @@ -1803,7 +1803,7 @@ mod tests {
fn test_case(list: List, selected: Option<usize>, expected_lines: Vec<&str>) {
let mut state = ListState::default();
state.select(selected);
let buffer = render_stateful_widget(list.clone(), &mut state, 15, 3);
let buffer = render_stateful_widget(list, &mut state, 15, 3);
let expected = Buffer::with_lines(expected_lines);
assert_buffer_eq!(buffer, expected);
}
Expand Down
1 change: 1 addition & 0 deletions src/widgets/paragraph.rs
Expand Up @@ -416,6 +416,7 @@ mod test {
/// area and comparing the rendered and expected content.
/// This can be used for easy testing of varying configured paragraphs with the same expected
/// buffer or any other test case really.
#[allow(clippy::needless_pass_by_value)]
fn test_case(paragraph: &Paragraph, expected: Buffer) {
let backend = TestBackend::new(expected.area.width, expected.area.height);
let mut terminal = Terminal::new(backend).unwrap();
Expand Down
1 change: 1 addition & 0 deletions src/widgets/reflow.rs
Expand Up @@ -344,6 +344,7 @@ mod test {
text::{Line, Text},
};

#[derive(Clone, Copy)]
enum Composer {
WordWrapper { trim: bool },
LineTruncator,
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/table/table.rs
Expand Up @@ -618,7 +618,7 @@ impl StatefulWidgetRef for Table<'_> {
&columns_widths,
);

self.render_footer(footer_area, buf, columns_widths);
self.render_footer(footer_area, buf, &columns_widths);
}
}

Expand Down Expand Up @@ -655,7 +655,7 @@ impl Table<'_> {
}
}

fn render_footer(&self, area: Rect, buf: &mut Buffer, column_widths: Vec<(u16, u16)>) {
fn render_footer(&self, area: Rect, buf: &mut Buffer, column_widths: &[(u16, u16)]) {
if let Some(ref footer) = self.footer {
buf.set_style(area, footer.style);
for ((x, width), cell) in column_widths.iter().zip(footer.cells.iter()) {
Expand Down

0 comments on commit 8195f52

Please sign in to comment.