From ddd3d126e94fbbc6e1ff83efb79dd0b5868df3de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 14 Dec 2017 06:32:48 +0100 Subject: [PATCH] selectors: Manually inline any(..) in matches_selector_list. Since the compiler refuses to inline the inner closure even with -O3, which is sad :(. Sad try run: https://treeherder.mozilla.org/perf.html#/compare?originalProject=try&originalRevision=c2724c47e98f990826327da05220cd83b772d144&newProject=try&newRevision=52ac88b40a08a5ef6a629bd681f2e5a444b75f54&framework=1 --- components/selectors/matching.rs | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/components/selectors/matching.rs b/components/selectors/matching.rs index a2d85e8986d..f9820cbc170 100644 --- a/components/selectors/matching.rs +++ b/components/selectors/matching.rs @@ -72,14 +72,24 @@ pub fn matches_selector_list( where E: Element { - selector_list.0.iter().any(|selector| { - matches_selector(selector, - 0, - None, - element, - context, - &mut |_, _| {}) - }) + // This is pretty much any(..) but manually inlined because the compiler + // refuses to do so from querySelector / querySelectorAll. + for selector in &selector_list.0 { + let matches = matches_selector( + selector, + 0, + None, + element, + context, + &mut |_, _| {}, + ); + + if matches { + return true; + } + } + + false } #[inline(always)]