Avoid cloning placeholder for PickList unnecessarily during draw
This commit is contained in:
parent
1b36068847
commit
a866f8742e
2 changed files with 6 additions and 4 deletions
|
|
@ -31,7 +31,7 @@ where
|
|||
bounds: Rectangle,
|
||||
cursor_position: Point,
|
||||
selected: Option<String>,
|
||||
placeholder: Option<String>,
|
||||
placeholder: Option<&str>,
|
||||
padding: Padding,
|
||||
text_size: u16,
|
||||
font: Font,
|
||||
|
|
@ -70,7 +70,9 @@ where
|
|||
|
||||
(
|
||||
Primitive::Group {
|
||||
primitives: if let Some(label) = selected.or(placeholder) {
|
||||
primitives: if let Some(label) =
|
||||
selected.or_else(|| placeholder.map(str::to_string))
|
||||
{
|
||||
let label = Primitive::Text {
|
||||
content: label,
|
||||
size: f32::from(text_size),
|
||||
|
|
|
|||
|
|
@ -285,7 +285,7 @@ where
|
|||
layout.bounds(),
|
||||
cursor_position,
|
||||
self.selected.as_ref().map(ToString::to_string),
|
||||
self.placeholder.clone(),
|
||||
self.placeholder.as_ref().map(String::as_str),
|
||||
self.padding,
|
||||
self.text_size.unwrap_or(renderer.default_size()),
|
||||
self.font,
|
||||
|
|
@ -346,7 +346,7 @@ pub trait Renderer: text::Renderer + menu::Renderer {
|
|||
bounds: Rectangle,
|
||||
cursor_position: Point,
|
||||
selected: Option<String>,
|
||||
placeholder: Option<String>,
|
||||
placeholder: Option<&str>,
|
||||
padding: Padding,
|
||||
text_size: u16,
|
||||
font: Self::Font,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue