mirror of
https://github.com/emilk/egui.git
synced 2026-06-26 22:53:14 -04:00
Use explicit Arc::clone to clarify when clones are cheap (#7784)
This commit is contained in:
@@ -123,7 +123,7 @@ fn adjust_color_mode(
|
||||
match color_mode {
|
||||
color::ColorMode::Solid(color) => adjust_color(color),
|
||||
color::ColorMode::UV(callback) => {
|
||||
let callback = callback.clone();
|
||||
let callback = Arc::clone(callback);
|
||||
*color_mode = color::ColorMode::UV(Arc::new(Box::new(move |rect, pos| {
|
||||
let mut color = callback(rect, pos);
|
||||
adjust_color(&mut color);
|
||||
|
||||
@@ -880,14 +880,14 @@ impl GalleyCache {
|
||||
let cached = entry.into_mut();
|
||||
cached.last_used = self.generation;
|
||||
|
||||
let galley = cached.galley.clone();
|
||||
let galley = Arc::clone(&cached.galley);
|
||||
if let Some(children) = &cached.children {
|
||||
// The point of `allow_split_paragraphs` is to split large jobs into paragraph,
|
||||
// and then cache each paragraph individually.
|
||||
// That way, if we edit a single paragraph, only that paragraph will be re-layouted.
|
||||
// For that to work we need to keep all the child/paragraph
|
||||
// galleys alive while the parent galley is alive:
|
||||
for child_hash in children.clone().iter() {
|
||||
for child_hash in Arc::clone(children).iter() {
|
||||
if let Some(cached_child) = self.cache.get_mut(child_hash) {
|
||||
cached_child.last_used = self.generation;
|
||||
}
|
||||
@@ -913,7 +913,7 @@ impl GalleyCache {
|
||||
CachedGalley {
|
||||
last_used: self.generation,
|
||||
children: Some(child_hashes.into()),
|
||||
galley: galley.clone(),
|
||||
galley: Arc::clone(&galley),
|
||||
},
|
||||
);
|
||||
galley
|
||||
@@ -923,7 +923,7 @@ impl GalleyCache {
|
||||
entry.insert(CachedGalley {
|
||||
last_used: self.generation,
|
||||
children: None,
|
||||
galley: galley.clone(),
|
||||
galley: Arc::clone(&galley),
|
||||
});
|
||||
galley
|
||||
}
|
||||
|
||||
@@ -876,7 +876,7 @@ impl Galley {
|
||||
ends_with_newline |= !is_last_galley && is_last_row_in_galley;
|
||||
super::PlacedRow {
|
||||
pos: new_pos,
|
||||
row: placed_row.row.clone(),
|
||||
row: Arc::clone(&placed_row.row),
|
||||
ends_with_newline,
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -32,7 +32,7 @@ impl Clone for TextureHandle {
|
||||
fn clone(&self) -> Self {
|
||||
self.tex_mngr.write().retain(self.id);
|
||||
Self {
|
||||
tex_mngr: self.tex_mngr.clone(),
|
||||
tex_mngr: Arc::clone(&self.tex_mngr),
|
||||
id: self.id,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user