Bug 1607697 - Address unwrap_or_else(callback) and functions in callback clippy lints. r=Gankro

I don't think it makes much of a difference but clippy is quite vocal about it.

Differential Revision: https://phabricator.services.mozilla.com/D59114

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nicolas Silva 2020-01-10 10:12:08 +00:00
Родитель 8dffbee87f
Коммит a5e19cec49
6 изменённых файлов: 15 добавлений и 12 удалений

Просмотреть файл

@ -600,7 +600,7 @@ pub fn compute_valid_tiles_if_bounds_change(
return Some(TileRange::zero());
}
let intersection = intersection.unwrap_or(DeviceIntRect::zero());
let intersection = intersection.unwrap_or_else(DeviceIntRect::zero);
let left = prev_rect.min_x() != new_rect.min_x();
let right = prev_rect.max_x() != new_rect.max_x();

Просмотреть файл

@ -41,6 +41,9 @@ doesn't only contain trivial geometry, it can also store another
[stacking_contexts]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context
*/
#![cfg_attr(feature = "cargo-clippy", allow(clippy::unreadable_literal, clippy::new_without_default, clippy::too_many_arguments))]
// Cribbed from the |matches| crate, for simplicity.
macro_rules! matches {
($expression:expr, $($pattern:tt)+) => {

Просмотреть файл

@ -742,7 +742,7 @@ impl Tile {
self.clipped_rect = self.rect
.intersection(&ctx.local_rect)
.and_then(|r| r.intersection(&ctx.local_clip_rect))
.unwrap_or(PictureRect::zero());
.unwrap_or_else(PictureRect::zero);
self.world_rect = ctx.pic_to_world_mapper
.map(&self.rect)
@ -938,7 +938,7 @@ impl Tile {
// Ensure that the dirty rect doesn't extend outside the local tile rect.
self.dirty_rect = self.dirty_rect
.intersection(&self.rect)
.unwrap_or(PictureRect::zero());
.unwrap_or_else(PictureRect::zero);
// See if this tile is a simple color, in which case we can just draw
// it as a rect, and avoid allocating a texture surface and drawing it.
@ -1828,7 +1828,7 @@ impl TileCacheInstance {
let needed_rect_in_pic_space = desired_rect_in_pic_space
.intersection(&pic_rect)
.unwrap_or(PictureRect::zero());
.unwrap_or_else(PictureRect::zero);
let p0 = needed_rect_in_pic_space.origin;
let p1 = needed_rect_in_pic_space.bottom_right();
@ -3611,7 +3611,7 @@ impl PicturePrimitive {
// the tile rects below for occlusion testing to the relevant area.
let local_clip_rect = tile_cache.local_rect
.intersection(&tile_cache.local_clip_rect)
.unwrap_or(PictureRect::zero());
.unwrap_or_else(PictureRect::zero);
let world_clip_rect = map_pic_to_world
.map(&local_clip_rect)

Просмотреть файл

@ -1452,7 +1452,7 @@ impl RenderTask {
if let RenderTaskKind::SvgFilter(ref mut filter_task) = self.kind {
match filter_task.info {
SvgFilterInfo::ColorMatrix(ref matrix) => {
let handle = filter_task.extra_gpu_cache_handle.get_or_insert_with(|| GpuCacheHandle::new());
let handle = filter_task.extra_gpu_cache_handle.get_or_insert_with(GpuCacheHandle::new);
if let Some(mut request) = gpu_cache.request(handle) {
for i in 0..5 {
request.push([matrix[i*4], matrix[i*4+1], matrix[i*4+2], matrix[i*4+3]]);
@ -1461,20 +1461,20 @@ impl RenderTask {
}
SvgFilterInfo::DropShadow(color) |
SvgFilterInfo::Flood(color) => {
let handle = filter_task.extra_gpu_cache_handle.get_or_insert_with(|| GpuCacheHandle::new());
let handle = filter_task.extra_gpu_cache_handle.get_or_insert_with(GpuCacheHandle::new);
if let Some(mut request) = gpu_cache.request(handle) {
request.push(color.to_array());
}
}
SvgFilterInfo::ComponentTransfer(ref data) => {
let handle = filter_task.extra_gpu_cache_handle.get_or_insert_with(|| GpuCacheHandle::new());
let handle = filter_task.extra_gpu_cache_handle.get_or_insert_with(GpuCacheHandle::new);
if let Some(request) = gpu_cache.request(handle) {
data.update(request);
}
}
SvgFilterInfo::Composite(ref operator) => {
if let CompositeOperator::Arithmetic(k_vals) = operator {
let handle = filter_task.extra_gpu_cache_handle.get_or_insert_with(|| GpuCacheHandle::new());
let handle = filter_task.extra_gpu_cache_handle.get_or_insert_with(GpuCacheHandle::new);
if let Some(mut request) = gpu_cache.request(handle) {
request.push(*k_vals);
}

Просмотреть файл

@ -937,7 +937,7 @@ impl ResourceCache {
tile,
).into();
rect.intersection(&tile_rect).unwrap_or(DeviceIntRect::zero())
rect.intersection(&tile_rect).unwrap_or_else(DeviceIntRect::zero)
})
}
(None, Some(..)) => DirtyRect::All,
@ -1020,7 +1020,7 @@ impl ResourceCache {
match (image.valid_tiles_after_bounds_change, valid_tiles_after_bounds_change) {
(Some(old), Some(ref mut new)) => {
*new = new.intersection(&old).unwrap_or(TileRange::zero());
*new = new.intersection(&old).unwrap_or_else(TileRange::zero);
}
(Some(old), None) => {
valid_tiles_after_bounds_change = Some(old);

Просмотреть файл

@ -664,7 +664,7 @@ impl<'a> SceneBuilder<'a> {
scroll_root,
slice.prim_list,
background_color,
slice.shared_clips.unwrap_or(Vec::new()),
slice.shared_clips.unwrap_or_else(Vec::new),
&mut self.interners,
&mut self.prim_store,
&mut self.clip_store,