Use SmallBitVec to replace BitVec

This commit is contained in:
Matt Brubeck 2017-09-08 21:11:23 -07:00
parent 4721ef81fd
commit 21006fb752
5 changed files with 17 additions and 11 deletions

View file

@ -34,7 +34,6 @@ arrayvec = "0.3.20"
arraydeque = "0.2.3"
atomic_refcell = "0.1"
bitflags = "0.7"
bit-vec = "0.4.3"
byteorder = "1.0"
cfg-if = "0.1.0"
cssparser = "0.20"
@ -65,6 +64,7 @@ serde = {version = "1.0", optional = true, features = ["derive"]}
servo_arc = { path = "../servo_arc" }
servo_atoms = {path = "../atoms", optional = true}
servo_config = {path = "../config", optional = true}
smallbitvec = "1.0"
smallvec = "0.4"
style_derive = {path = "../style_derive"}
style_traits = {path = "../style_traits"}

View file

@ -40,7 +40,6 @@
extern crate app_units;
extern crate arrayvec;
extern crate atomic_refcell;
extern crate bit_vec;
#[macro_use]
extern crate bitflags;
#[allow(unused_extern_crates)] extern crate byteorder;
@ -80,6 +79,7 @@ pub extern crate servo_arc;
#[cfg(feature = "servo")] #[macro_use] extern crate servo_atoms;
#[cfg(feature = "servo")] extern crate servo_config;
#[cfg(feature = "servo")] extern crate servo_url;
extern crate smallbitvec;
extern crate smallvec;
#[macro_use]
extern crate style_derive;

View file

@ -67,7 +67,6 @@
use Atom;
use applicable_declarations::ApplicableDeclarationBlock;
use atomic_refcell::{AtomicRefCell, AtomicRefMut};
use bit_vec::BitVec;
use bloom::StyleBloom;
use cache::{LRUCache, LRUCacheMutIterator};
use context::{SelectorFlagsMap, SharedStyleContext, StyleContext};
@ -78,6 +77,7 @@ use owning_ref::OwningHandle;
use properties::ComputedValues;
use selectors::matching::{ElementSelectorFlags, VisitedHandlingMode};
use servo_arc::Arc;
use smallbitvec::SmallBitVec;
use smallvec::SmallVec;
use std::marker::PhantomData;
use std::mem;
@ -123,7 +123,7 @@ pub struct ValidationData {
/// The cached result of matching this entry against the revalidation
/// selectors.
revalidation_match_results: Option<BitVec>,
revalidation_match_results: Option<SmallBitVec>,
}
impl ValidationData {
@ -177,7 +177,7 @@ impl ValidationData {
bloom: &StyleBloom<E>,
bloom_known_valid: bool,
flags_setter: &mut F
) -> &BitVec
) -> &SmallBitVec
where E: TElement,
F: FnMut(&E, ElementSelectorFlags),
{
@ -256,7 +256,7 @@ impl<E: TElement> StyleSharingCandidate<E> {
&mut self,
stylist: &Stylist,
bloom: &StyleBloom<E>,
) -> &BitVec {
) -> &SmallBitVec {
self.validation_data.revalidation_match_results(
self.element,
stylist,
@ -309,7 +309,7 @@ impl<E: TElement> StyleSharingTarget<E> {
stylist: &Stylist,
bloom: &StyleBloom<E>,
selector_flags_map: &mut SelectorFlagsMap<E>
) -> &BitVec {
) -> &SmallBitVec {
// It's important to set the selector flags. Otherwise, if we succeed in
// sharing the style, we may not set the slow selector flags for the
// right elements (which may not necessarily be |element|), causing

View file

@ -6,7 +6,6 @@
use {Atom, LocalName, Namespace};
use applicable_declarations::{ApplicableDeclarationBlock, ApplicableDeclarationList};
use bit_vec::BitVec;
use context::{CascadeInputs, QuirksMode};
use dom::TElement;
use element_state::ElementState;
@ -34,6 +33,7 @@ use selectors::sink::Push;
use selectors::visitor::SelectorVisitor;
use servo_arc::{Arc, ArcBorrow};
use shared_lock::{Locked, SharedRwLockReadGuard, StylesheetGuards};
use smallbitvec::SmallBitVec;
use smallvec::VecLike;
use std::fmt::Debug;
use std::ops;
@ -1493,7 +1493,7 @@ impl Stylist {
element: &E,
bloom: Option<&BloomFilter>,
flags_setter: &mut F
) -> BitVec
) -> SmallBitVec
where
E: TElement,
F: FnMut(&E, ElementSelectorFlags),
@ -1508,7 +1508,7 @@ impl Stylist {
// This means we're guaranteed to get the same rulehash buckets for all
// the lookups, which means that the bitvecs are comparable. We verify
// this in the caller by asserting that the bitvecs are same-length.
let mut results = BitVec::new();
let mut results = SmallBitVec::new();
for (data, _) in self.cascade_data.iter_origins() {
data.selectors_for_cache_revalidation.lookup(
*element,