Skip to content
This repository has been archived by the owner on Aug 6, 2023. It is now read-only.

Commit

Permalink
refactor(widgets): remove iter::repeat for blank symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
fdehau committed Aug 1, 2021
1 parent 34a2be6 commit 8eb6336
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
5 changes: 1 addition & 4 deletions src/widgets/list.rs
Expand Up @@ -5,7 +5,6 @@ use crate::{
text::Text,
widgets::{Block, StatefulWidget, Widget},
};
use std::iter::{self, Iterator};
use unicode_width::UnicodeWidthStr;

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -185,9 +184,7 @@ impl<'a> StatefulWidget for List<'a> {
state.offset = start;

let highlight_symbol = self.highlight_symbol.unwrap_or("");
let blank_symbol = iter::repeat(" ")
.take(highlight_symbol.width())
.collect::<String>();
let blank_symbol = " ".repeat(highlight_symbol.width());

let mut current_height = 0;
let has_selection = state.selected.is_some();
Expand Down
9 changes: 2 additions & 7 deletions src/widgets/table.rs
Expand Up @@ -10,10 +10,7 @@ use cassowary::{
WeightedRelation::*,
{Expression, Solver},
};
use std::{
collections::HashMap,
iter::{self, Iterator},
};
use std::collections::HashMap;
use unicode_width::UnicodeWidthStr;

/// A [`Cell`] contains the [`Text`] to be displayed in a [`Row`] of a [`Table`].
Expand Down Expand Up @@ -427,9 +424,7 @@ impl<'a> StatefulWidget for Table<'a> {
let has_selection = state.selected.is_some();
let columns_widths = self.get_columns_widths(table_area.width, has_selection);
let highlight_symbol = self.highlight_symbol.unwrap_or("");
let blank_symbol = iter::repeat(" ")
.take(highlight_symbol.width())
.collect::<String>();
let blank_symbol = " ".repeat(highlight_symbol.width());
let mut current_height = 0;
let mut rows_height = table_area.height;

Expand Down

0 comments on commit 8eb6336

Please sign in to comment.