1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-29 04:40:03 -04:00

Use explicit Arc::clone to clarify when clones are cheap (#7784)

This commit is contained in:
Emil Ernerfeldt
2025-12-17 17:19:18 +01:00
committed by GitHub
parent 6157a35985
commit 986c2c0ffb
40 changed files with 80 additions and 71 deletions

View File

@@ -75,7 +75,7 @@ impl BytesLoader for FileLoader {
.name(format!("egui_extras::FileLoader::load({uri:?})"))
.spawn({
let ctx = ctx.clone();
let cache = self.cache.clone();
let cache = Arc::clone(&self.cache);
let uri = uri.to_owned();
move || {
let result = match std::fs::read(&path) {

View File

@@ -53,7 +53,7 @@ impl AnimatedImage {
/// Gets image at index
pub fn get_image(&self, index: usize) -> Arc<ColorImage> {
self.frames[index % self.frames.len()].clone()
Arc::clone(&self.frames[index % self.frames.len()])
}
}
type Entry = Result<Arc<AnimatedImage>, String>;

View File

@@ -84,7 +84,7 @@ impl BytesLoader for EhttpLoader {
ehttp::fetch(ehttp::Request::get(uri.clone()), {
let ctx = ctx.clone();
let cache = self.cache.clone();
let cache = Arc::clone(&self.cache);
move |response| {
let result = match response {
Ok(response) => File::from_response(&uri, response),

View File

@@ -94,7 +94,7 @@ impl ImageLoader for ImageCrateLoader {
.name(format!("egui_extras::ImageLoader::load({uri:?})"))
.spawn({
let ctx = ctx.clone();
let cache = cache.clone();
let cache = Arc::clone(cache);
let uri = uri.clone();
let bytes = bytes.clone();

View File

@@ -75,7 +75,7 @@ impl WebP {
fn get_image(&self, frame_index: usize) -> Arc<ColorImage> {
match self {
Self::Static(image) => image.clone(),
Self::Static(image) => Arc::clone(image),
Self::Animated(animation) => animation.get_image_by_index(frame_index),
}
}
@@ -108,7 +108,7 @@ impl AnimatedImage {
}
pub fn get_image_by_index(&self, index: usize) -> Arc<ColorImage> {
self.frames[index % self.frames.len()].clone()
Arc::clone(&self.frames[index % self.frames.len()])
}
}