Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a new infrastructure for presentational hints. #5857

Merged
merged 5 commits into from Apr 28, 2015
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Avoid creating a vector in can_share_style_with.

  • Loading branch information
Ms2ger committed Apr 27, 2015
commit 811ea395bc71b7b667f293c75b83db92b3e28a78
@@ -20,6 +20,7 @@ use selectors::bloom::BloomFilter;
use selectors::matching::{CommonStyleAffectingAttributeMode, CommonStyleAffectingAttributes};
use selectors::matching::{common_style_affecting_attributes, rare_style_affecting_attributes};
use selectors::parser::PseudoElement;
use selectors::smallvec::VecLike;
use std::borrow::ToOwned;
use std::hash::{Hash, Hasher};
use std::mem;
@@ -289,9 +290,29 @@ impl StyleSharingCandidate {
return false
}

let mut matching_rules = vec![];
struct RulesSink {
empty: bool,
}
impl<T> VecLike<T> for RulesSink {
#[inline]
fn vec_len(&self) -> usize {
unreachable!()
}

#[inline]
fn vec_push(&mut self, _value: T) {
self.empty = false;
}

#[inline]
fn vec_slice_mut<'a>(&'a mut self, _start: usize, _end: usize)
-> &'a mut [T] {
unreachable!()
}
}
let mut matching_rules = RulesSink { empty: true };
element.synthesize_presentational_hints_for_legacy_attributes(&mut matching_rules);
if !matching_rules.is_empty() {
if !matching_rules.empty {
return false;
}

This comment has been minimized.

@pcwalton

pcwalton Apr 27, 2015

Contributor

This is probably going to be too slow. can_share_style_with is called zillions of times. Can you avoid creating the vector?


ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.