Bug 1607697 - Pass-by-value clippy lints for some small structures. r=Gankro
☠☠ backed out by c2dd65b196d3 ☠ ☠
authorNicolas Silva <nsilva@mozilla.com>
Wed, 08 Jan 2020 15:41:12 +0000
changeset 509367 3af5a9700d47aedf0db0457d86046b6bda1c178b
parent 509366 6101f5e31e46f6c77198c66e14a56ea2510e7c92
child 509368 6bf3305bb6893affecdbde816a7bf856a7ed13f1
push id36995
push userapavel@mozilla.com
push dateWed, 08 Jan 2020 21:56:06 +0000
treeherdermozilla-central@374a48ce8690 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGankro
bugs1607697
milestone74.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1607697 - Pass-by-value clippy lints for some small structures. r=Gankro Differential Revision: https://phabricator.services.mozilla.com/D59116
gfx/wr/webrender/src/prim_store/mod.rs
gfx/wr/webrender/src/render_backend.rs
gfx/wr/webrender/src/renderer.rs
gfx/wr/webrender/src/resource_cache.rs
gfx/wr/webrender/src/storage.rs
gfx/wr/webrender/src/texture_cache.rs
--- a/gfx/wr/webrender/src/prim_store/mod.rs
+++ b/gfx/wr/webrender/src/prim_store/mod.rs
@@ -120,17 +120,17 @@ impl PrimitiveOpacity {
     }
 
     pub fn from_alpha(alpha: f32) -> PrimitiveOpacity {
         PrimitiveOpacity {
             is_opaque: alpha >= 1.0,
         }
     }
 
-    pub fn combine(&self, other: PrimitiveOpacity) -> PrimitiveOpacity {
+    pub fn combine(self, other: PrimitiveOpacity) -> PrimitiveOpacity {
         PrimitiveOpacity{
             is_opaque: self.is_opaque && other.is_opaque
         }
     }
 }
 
 #[derive(Clone, Debug)]
 pub struct SpaceSnapper {
@@ -373,23 +373,23 @@ impl ClipTaskIndex {
 }
 
 #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, MallocSizeOf, Ord, PartialOrd)]
 #[cfg_attr(feature = "capture", derive(Serialize))]
 #[cfg_attr(feature = "replay", derive(Deserialize))]
 pub struct PictureIndex(pub usize);
 
 impl GpuCacheHandle {
-    pub fn as_int(&self, gpu_cache: &GpuCache) -> i32 {
+    pub fn as_int(self, gpu_cache: &GpuCache) -> i32 {
         gpu_cache.get_address(self).as_int()
     }
 }
 
 impl GpuCacheAddress {
-    pub fn as_int(&self) -> i32 {
+    pub fn as_int(self) -> i32 {
         // TODO(gw): Temporarily encode GPU Cache addresses as a single int.
         //           In the future, we can change the PrimitiveInstanceData struct
         //           to use 2x u16 for the vertex attribute instead of an i32.
         self.v as i32 * MAX_VERTEX_TEXTURE_WIDTH as i32 + self.u as i32
     }
 }
 
 /// The information about an interned primitive that
--- a/gfx/wr/webrender/src/render_backend.rs
+++ b/gfx/wr/webrender/src/render_backend.rs
@@ -1627,29 +1627,29 @@ impl RenderBackend {
             doc.scene.clip_scroll_tree.print_with(&mut builder);
 
             debug_root.add(builder.build());
         }
 
         serde_json::to_string(&debug_root).unwrap()
     }
 
-    fn report_memory(&mut self, tx: MsgSender<MemoryReport>) {
-        let mut report = MemoryReport::default();
+    fn report_memory(&mut self, tx: MsgSender<Box<MemoryReport>>) {
+        let mut report = Box::new(MemoryReport::default());
         let ops = self.size_of_ops.as_mut().unwrap();
         let op = ops.size_of_op;
         report.gpu_cache_metadata = self.gpu_cache.size_of(ops);
-        for (_id, doc) in &self.documents {
+        for doc in self.documents.values() {
             report.clip_stores += doc.scene.clip_store.size_of(ops);
             report.hit_testers += doc.hit_tester.size_of(ops);
 
             doc.data_stores.report_memory(ops, &mut report)
         }
 
-        report += self.resource_cache.report_memory(op);
+        (*report) += self.resource_cache.report_memory(op);
 
         // Send a message to report memory on the scene-builder thread, which
         // will add its report to this one and send the result back to the original
         // thread waiting on the request.
         self.scene_tx.send(SceneBuilderRequest::ReportMemory(report, tx)).unwrap();
     }
 }
 
@@ -1880,17 +1880,17 @@ impl RenderBackend {
                     // it (but we do want to update the scene builder's state)
                     false
                 }
                 None => true,
             };
 
             scenes_to_build.push(LoadScene {
                 document_id: id,
-                scene: scene,
+                scene,
                 view: view.clone(),
                 config: self.frame_config.clone(),
                 output_pipelines: doc.output_pipelines.clone(),
                 font_instances: self.resource_cache.get_font_instances(),
                 build_frame,
                 interners,
             });
 
--- a/gfx/wr/webrender/src/renderer.rs
+++ b/gfx/wr/webrender/src/renderer.rs
@@ -3925,17 +3925,17 @@ impl Renderer {
 
             // Draw opaque batches front-to-back for maximum
             // z-buffer efficiency!
             for batch in alpha_batch_container
                 .opaque_batches
                 .iter()
                 .rev()
                 {
-                    if should_skip_batch(&batch.key.kind, &self.debug_flags) {
+                    if should_skip_batch(&batch.key.kind, self.debug_flags) {
                         continue;
                     }
 
                     self.shaders.borrow_mut()
                         .get(&batch.key, batch.features, self.debug_flags)
                         .bind(
                             &mut self.device, projection,
                             &mut self.renderer_errors,
@@ -3976,17 +3976,17 @@ impl Renderer {
                 self.init_pixel_local_storage(
                     alpha_batch_container.task_rect,
                     projection,
                     stats,
                 );
             }
 
             for batch in &alpha_batch_container.alpha_batches {
-                if should_skip_batch(&batch.key.kind, &self.debug_flags) {
+                if should_skip_batch(&batch.key.kind, self.debug_flags) {
                     continue;
                 }
 
                 let mut shaders = shaders_rc.borrow_mut();
                 let shader = shaders.get(
                     &batch.key,
                     batch.features | BatchFeatures::ALPHA_PASS,
                     self.debug_flags,
@@ -6779,17 +6779,17 @@ fn get_vao<'a>(vertex_array_kind: Vertex
     }
 }
 #[derive(Clone, Copy, PartialEq)]
 enum FramebufferKind {
     Main,
     Other,
 }
 
-fn should_skip_batch(kind: &BatchKind, flags: &DebugFlags) -> bool {
+fn should_skip_batch(kind: &BatchKind, flags: DebugFlags) -> bool {
     match kind {
         BatchKind::TextRun(_) => {
             flags.contains(DebugFlags::DISABLE_TEXT_PRIMS)
         }
         BatchKind::Brush(BrushBatchKind::RadialGradient) |
         BatchKind::Brush(BrushBatchKind::LinearGradient) => {
             flags.contains(DebugFlags::DISABLE_GRADIENT_PRIMS)
         }
--- a/gfx/wr/webrender/src/resource_cache.rs
+++ b/gfx/wr/webrender/src/resource_cache.rs
@@ -395,17 +395,17 @@ enum ImageResult {
 impl ImageResult {
     /// Releases any texture cache entries held alive by this ImageResult.
     fn drop_from_cache(&mut self, texture_cache: &mut TextureCache) {
         match *self {
             ImageResult::UntiledAuto(ref mut entry) => {
                 entry.mark_unused(texture_cache);
             },
             ImageResult::Multi(ref mut entries) => {
-                for (_, entry) in &mut entries.resources {
+                for entry in entries.resources.values_mut() {
                     entry.mark_unused(texture_cache);
                 }
             },
             ImageResult::Err(_) => {},
         }
     }
 }
 
--- a/gfx/wr/webrender/src/storage.rs
+++ b/gfx/wr/webrender/src/storage.rs
@@ -55,17 +55,17 @@ impl<T> Range<T> {
     pub fn empty() -> Self {
         Range {
             start: Index::new(0),
             end: Index::new(0),
         }
     }
 
     /// Check for an empty `Range`
-    pub fn is_empty(&self) -> bool {
+    pub fn is_empty(self) -> bool {
         self.start.0 >= self.end.0
     }
 }
 
 #[cfg_attr(feature = "capture", derive(Serialize))]
 pub struct Storage<T> {
     data: Vec<T>,
 }
--- a/gfx/wr/webrender/src/texture_cache.rs
+++ b/gfx/wr/webrender/src/texture_cache.rs
@@ -983,17 +983,17 @@ impl TextureCache {
 
         // Create an update command, which the render thread processes
         // to upload the new image data into the correct location
         // in GPU memory.
         if let Some(data) = data {
             // If the swizzling is supported, we always upload in the internal
             // texture format (thus avoiding the conversion by the driver).
             // Otherwise, pass the external format to the driver.
-            let use_upload_format = !self.swizzle.is_some();
+            let use_upload_format = self.swizzle.is_none();
             let (layer_index, origin) = entry.details.describe();
             let op = TextureCacheUpdate::new_update(
                 data,
                 &descriptor,
                 origin,
                 entry.size,
                 layer_index as i32,
                 use_upload_format,