Bug 1557721 - Use or_insert_with where possible. r=kvark
authorBruce Mitchener <bruce.mitchener@gmail.com>
Fri, 07 Jun 2019 16:17:52 +0000
changeset 477881 5d31dd07595a0485d74f4653dbaf2aed5e38ac10
parent 477880 1d9c323e12cef1ee5878bc65c4ad8cd17bd9a889
child 477882 64ea2a3f0d4dd88bd83a03b811ecf4197a2723c8
push id36125
push userapavel@mozilla.com
push dateFri, 07 Jun 2019 22:00:07 +0000
treeherdermozilla-central@d820bbb356aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskvark
bugs1557721
milestone69.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 1557721 - Use or_insert_with where possible. r=kvark [wrupdater] From https://github.com/servo/webrender/pull/3667 Depends on D34162 Differential Revision: https://phabricator.services.mozilla.com/D34164
gfx/wr/webrender/src/batch.rs
gfx/wr/webrender/src/scene_builder.rs
gfx/wr/webrender/src/tiling.rs
--- a/gfx/wr/webrender/src/batch.rs
+++ b/gfx/wr/webrender/src/batch.rs
@@ -3028,17 +3028,17 @@ impl ClipBatcher {
                                 debug!("request: {:?}", request);
                                 return;
                             }
                         };
 
                         self.get_batch_list(is_first_clip)
                             .images
                             .entry(cache_item.texture_id)
-                            .or_insert(Vec::new())
+                            .or_insert_with(Vec::new)
                             .push(ClipMaskInstance {
                                 clip_data_address,
                                 resource_address: gpu_cache.get_address(&cache_item.uv_rect_handle),
                                 tile_rect: local_tile_rect,
                                 ..instance
                             });
                     };
 
@@ -3070,17 +3070,17 @@ impl ClipBatcher {
                         .get_cached_render_task(rt_handle);
                     let cache_item = resource_cache
                         .get_texture_cache_item(&rt_cache_entry.handle);
                     debug_assert_ne!(cache_item.texture_id, TextureSource::Invalid);
 
                     self.get_batch_list(is_first_clip)
                         .box_shadows
                         .entry(cache_item.texture_id)
-                        .or_insert(Vec::new())
+                        .or_insert_with(Vec::new)
                         .push(ClipMaskInstance {
                             clip_data_address: gpu_address,
                             resource_address: gpu_cache.get_address(&cache_item.uv_rect_handle),
                             ..instance
                         });
 
                     true
                 }
--- a/gfx/wr/webrender/src/scene_builder.rs
+++ b/gfx/wr/webrender/src/scene_builder.rs
@@ -457,17 +457,17 @@ impl SceneBuilder {
         if let &Some(ref hooks) = &self.hooks {
             hooks.pre_scene_build();
         }
 
         let scene_build_start_time = precise_time_ns();
 
         let doc = self.documents
                       .entry(txn.document_id)
-                      .or_insert(Document::new(Scene::new()));
+                      .or_insert_with(|| Document::new(Scene::new()));
         let scene = &mut doc.scene;
 
         for update in txn.display_list_updates.drain(..) {
             scene.set_display_list(
                 update.pipeline_id,
                 update.epoch,
                 update.built_display_list,
                 update.background,
--- a/gfx/wr/webrender/src/tiling.rs
+++ b/gfx/wr/webrender/src/tiling.rs
@@ -1110,17 +1110,17 @@ impl RenderPass {
 
                         (target_kind, texture_target, layer)
                     };
 
                     match texture_target {
                         Some(texture_target) => {
                             let texture = texture_cache
                                 .entry((texture_target, layer))
-                                .or_insert(
+                                .or_insert_with(||
                                     TextureCacheRenderTarget::new(target_kind)
                                 );
                             texture.add_task(task_id, render_tasks);
                         }
                         None => {
                             match target_kind {
                                 RenderTargetKind::Color => color.targets[layer].add_task(
                                     task_id,