Skip to content

Commit c025437

Browse files
committed
Bug 1747409 - Use iter().all() in clip nodes during hit testing rather than a nested loop. r=gfx-reviewers,bradwerth,kvark
Shouldn't change behavior but wrote this drive-by. Depends on D136894 Differential Revision: https://phabricator.services.mozilla.com/D136895 [ghsync] From https://hg.mozilla.org/mozilla-central/rev/e6df83a893d147247c43b49e1f8527ebbaf11fcd
1 parent dcf2026 commit c025437

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

webrender/src/hit_test.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,8 @@ impl HitTester {
407407
}
408408

409409
// See if any of the clips for this primitive cull out the item.
410-
let mut is_valid = true;
411410
let clip_nodes = &self.scene.clip_nodes[item.clip_nodes_range.start.0 as usize .. item.clip_nodes_range.end.0 as usize];
412-
for clip_node in clip_nodes {
411+
let is_valid = clip_nodes.iter().all(|clip_node| {
413412
let transform = self
414413
.spatial_nodes[&clip_node.spatial_node_index]
415414
.world_content_transform;
@@ -418,13 +417,13 @@ impl HitTester {
418417
.and_then(|inverted| inverted.transform_point2d(test.point))
419418
{
420419
Some(point) => point,
421-
None => continue,
420+
// XXX This `return true` is a bit sketchy, but matches
421+
// pre-existing behavior.
422+
None => return true,
422423
};
423-
if !clip_node.region.contains(&transformed_point) {
424-
is_valid = false;
425-
break;
426-
}
427-
}
424+
clip_node.region.contains(&transformed_point)
425+
});
426+
428427
if !is_valid {
429428
continue;
430429
}

0 commit comments

Comments
 (0)