mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Move the sink into util::vec.
This commit is contained in:
parent
811ea395bc
commit
ed052bc080
2 changed files with 39 additions and 23 deletions
|
@ -20,7 +20,6 @@ use selectors::bloom::BloomFilter;
|
||||||
use selectors::matching::{CommonStyleAffectingAttributeMode, CommonStyleAffectingAttributes};
|
use selectors::matching::{CommonStyleAffectingAttributeMode, CommonStyleAffectingAttributes};
|
||||||
use selectors::matching::{common_style_affecting_attributes, rare_style_affecting_attributes};
|
use selectors::matching::{common_style_affecting_attributes, rare_style_affecting_attributes};
|
||||||
use selectors::parser::PseudoElement;
|
use selectors::parser::PseudoElement;
|
||||||
use selectors::smallvec::VecLike;
|
|
||||||
use std::borrow::ToOwned;
|
use std::borrow::ToOwned;
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
@ -35,6 +34,7 @@ use util::arc_ptr_eq;
|
||||||
use util::cache::{LRUCache, SimpleHashCache};
|
use util::cache::{LRUCache, SimpleHashCache};
|
||||||
use util::opts;
|
use util::opts;
|
||||||
use util::smallvec::{SmallVec, SmallVec16};
|
use util::smallvec::{SmallVec, SmallVec16};
|
||||||
|
use util::vec::ForgetfulSink;
|
||||||
|
|
||||||
pub struct ApplicableDeclarations {
|
pub struct ApplicableDeclarations {
|
||||||
pub normal: SmallVec16<DeclarationBlock>,
|
pub normal: SmallVec16<DeclarationBlock>,
|
||||||
|
@ -290,29 +290,9 @@ impl StyleSharingCandidate {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RulesSink {
|
let mut matching_rules = ForgetfulSink::new();
|
||||||
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);
|
element.synthesize_presentational_hints_for_legacy_attributes(&mut matching_rules);
|
||||||
if !matching_rules.empty {
|
if !matching_rules.is_empty() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
use selectors::smallvec::VecLike;
|
||||||
|
|
||||||
use std::cmp::{PartialOrd, PartialEq, Ordering};
|
use std::cmp::{PartialOrd, PartialEq, Ordering};
|
||||||
use std::iter::range_step;
|
use std::iter::range_step;
|
||||||
|
|
||||||
|
@ -72,3 +74,37 @@ pub fn byte_swap(data: &mut [u8]) {
|
||||||
data[i + 0] = r;
|
data[i + 0] = r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A `VecLike` that only tracks whether or not something was ever pushed to it.
|
||||||
|
pub struct ForgetfulSink {
|
||||||
|
empty: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ForgetfulSink {
|
||||||
|
pub fn new() -> ForgetfulSink {
|
||||||
|
ForgetfulSink {
|
||||||
|
empty: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn is_empty(&self) -> bool {
|
||||||
|
self.empty
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> VecLike<T> for ForgetfulSink {
|
||||||
|
#[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!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue